基本-コインの送金
例を見てください。
import * as Quras from `quras-js` const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN); Quras.api.qurasDB.getBalance(Quras.CONST.QURAS_NETWORK.MAIN, 'DknmAbcap8RnUpkLQvbXTwTXqFJMjN4QPz') // Get the balance of from address. .then((data) => { const balance = new Quras.wallet.Balance(data) var scriptHash = Quras.wallet.getScriptHashFromAddress('Dqf3UKe1f5FBWduGxHp8RMqP29dL6DgGS1'); // To address. const outputs = [{ assetId: Quras.CONST.ASSET_ID['XQC'], // The type of coins that you want to send. value: 2, // Coin amount to send. scriptHash: scriptHash // The scripthash of "To address". }] const testTx = Quras.tx.Transaction.createContractTx(balance, outputs) // create a transaction. testTx.sign('20164b85226c67cb6d8fe114f3b91af3f2dfc52dcf05d708e9eca80c8d739481'); // Sign the transaction using private key rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server. .then((data) => { console.log(data); }) .catch ((error) => { console.log("error"); }); }) .catch((error) => { console.log(error) });
上記のように他のアドレスへコインを送金することができます。