diff --git a/bin/near b/bin/near index 5fcf8e0c..90a1bf76 100755 --- a/bin/near +++ b/bin/near @@ -46,6 +46,13 @@ const callViewFunction = { handler: (argv) => exitOnError(main.callViewFunction(argv)) }; +const sendTokens = { + command: 'send ', + desc: 'send tokens to given receiver', + builder: (yargs) => yargs, + handler: (argv) => exitOnError(main.sendTokens(argv)) +}; + const { spawn } = require('child_process'); const build = { command: 'build', @@ -129,6 +136,7 @@ yargs // eslint-disable-line .command(deploy) .command(scheduleFunctionCall) .command(callViewFunction) + .command(sendTokens) .command(clean) .command(newProject) .config(config) diff --git a/index.js b/index.js index 7674c9a2..2787d390 100755 --- a/index.js +++ b/index.js @@ -93,6 +93,13 @@ exports.scheduleFunctionCall = async function(options) { options.contractName, options.methodName, JSON.parse(options.args || '{}')))); }; +exports.sendTokens = async function(options) { + console.log(`Sending ${options.amount} NEAR to ${options.receiver}`); + const near = await connect(options); + await near.waitForTransactionResult( + await near.sendTokens(options.amount, options.accountId, options.receiver)); +}; + exports.callViewFunction = async function(options) { console.log(`View call: ${options.contractName}.${options.methodName}(${options.args || ''})`); const near = await connect(options);