0

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

0

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.

3
  • i tried this but it only increases Cpu ,net only not showing ram iincreased – Awais Sakhi May 4 at 4:03
  • did 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, } – Szabó Bence May 4 at 11:26
  • got it thanks its solved – Awais Sakhi May 5 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.