Skip to content

Commit

Permalink
chore(example): Transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Oct 20, 2023
1 parent 1e000f2 commit 7094b6e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/nodejs/transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { client, selectSp, generateString } = require('./client');
const { ACCOUNT_ADDRESS, ACCOUNT_PRIVATEKEY } = require('./env');

(async () => {
const transferTx = await client.account.transfer({
fromAddress: ACCOUNT_ADDRESS,
toAddress: '0x0000000000000000000000000000000000000001',
amount: [
{
denom: 'BNB',
amount: '1',
},
],
});

const simulateInfo = await transferTx.simulate({
denom: 'BNB',
});

console.log('simulateInfo', simulateInfo);

const res = await transferTx.broadcast({
denom: 'BNB',
gasLimit: Number(simulateInfo.gasLimit),
gasPrice: simulateInfo.gasPrice,
payer: ACCOUNT_ADDRESS,
granter: '',
privateKey: ACCOUNT_PRIVATEKEY,
});

console.log('res', res);
})();

0 comments on commit 7094b6e

Please sign in to comment.