我想在我的网站上做效用,这样那些不喜欢产品的人就可以在我们的网站上拿回他们的钱。通过单击submit按钮,我希望将usdt (TRC或ERC)发回给客户。甚至有可能。我觉得有可能是索拉娜区块链。例如,幻影钱包中有自动批准。但我需要在USDT
客户将以邮寄方式输入他的地址,并自动将usdt发送给他。
发布于 2022-06-29 12:56:39
您可以将发送方地址的私钥传递给web3.js或任何其他包装器(以太 for JS,web3.php for PHP,.)以太节点的JSON。您可以运行自己的节点,但更常见的情况是使用第三方节点提供程序(如恩弗拉 )。
web3.js实例构建事务,使用私钥对其进行签名,并将其发送到该节点以广播到网络的其余部分(Ethereum、Tron或其他取决于连接到哪个网络的节点)。
使用web3js的示例:
const Web3 = require("web3");
const web3 = new Web3(NODE_URL);
const USDTAddress = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
// just the `transfer()` function is sufficient in this case
const ERC20_ABI = [
{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},
];
// you're passing the private key just to the local web3js instance
// it's not broadcasted to the node
web3.eth.accounts.wallet.add(PRIVATE_KEY_OF_SENDER_ADDRESS);
async function run() {
const tokenContract = new Web3.eth.Contract(USDTAddress, ERC20_ABI);
const to = "0x123";
const amount = "1000000"; // don't forget to account for the decimals
// invoking the `transfer()` function of the contract
const transaction = await tokenContract.methods.transfer(to, amount).send({from: SENDER_ADDRESS});
}
run();https://stackoverflow.com/questions/72800889
复制相似问题