首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Erc-20令牌发送事务

Erc-20令牌发送事务
EN

Ethereum用户
提问于 2019-11-18 07:41:32
回答 1查看 405关注 0票数 0

我想要一些关于Erc-20交易的信息。我想把Erc-20托肯从第一个钱包转移到第二个钱包,我有女贞钥匙,但我想和Api一起传输,那么我如何传输Erc-20令牌呢?

EN

回答 1

Ethereum用户

发布于 2019-11-18 08:22:40

安装NodeJS。

运行npm install web3@1.2.1

实现文件send.js

代码语言:javascript
复制
const Web3 = require("web3");

async function send(value, firstWalletPrivateKey, secondWalletPublicAddress) {
    const web3 = new Web3("https://mainnet.infura.io");
    const options = {
        value   : value,
        gas     : 21000,
        to      : secondWalletPublicAddress,
        gasPrice: await web3.eth.getGasPrice()
    };
    const signedTx  = await web3.eth.accounts.signTransaction(options, firstWalletPrivateKey);
    const txReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log(JSON.stringify(txReceipt, null, 4));
}

send(your_value, your_firstWalletPrivateKey, your_secondWalletPublicAddress);

运行node send.js

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/77584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档