Hello i want to make api for buying RAM so is there any api available or any library please let me know but im already using eosjs ,eos-api of nodejs please let me know in comment thank you
1 Answer
You can use eosjs to solve this.
According to the documentation here: https://developers.eos.io/manuals/eosjs/latest/how-to-guides/how-to-stake
You can stake for resources. The example below is staking for NET and CPU for the user "mynewaccount" in the name of "useraaaaaaaa". I assume if you provide the "stake_ram_quantity" it will work.
(async () => {
await api.transact({
actions: [{
account: 'eosio',
name: 'delegatebw',
authorization: [{
actor: 'useraaaaaaaa',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
receiver: 'mynewaccount',
stake_net_quantity: '1.0000 SYS',
stake_cpu_quantity: '1.0000 SYS',
transfer: false,
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
})();
So you really only need to push eosio::delegatebw action which you can check out on bloks.io for more information.
-
i tried this but it only increases Cpu ,net only not showing ram iincreased Commented May 4, 2021 at 4:03
-
1did you delete the "stake_net_quantity" and "stake_cpu_quantity" variables from the "data" object and use only "stake_ram_quantity" instead? I mean something like this:data: { from: 'useraaaaaaaa', receiver: 'mynewaccount', stake_ram_quantity: '1.0000 SYS', transfer: false, } Commented May 4, 2021 at 11:26
-