0

我想为我的网站集成 USDT (ERC20) 合约,我将为用户生成一个存款地址。我将在一天结束时将所有余额提取到我自己的钱包中。

我参考https://etherscan.io/token/0xdac17f958d2ee523a2206206994597c13d831ec7遵循代码,我只是以 ABI “totalSupply” 的一部分为例。并成功获取返回值。

         var contractABI = @"[{""constant"": true,""inputs"": [],""name"": ""totalSupply"",""outputs"": [{""name"": """",""type"": ""uint256""}],""payable"": false,""stateMutability"": ""view"",""type"": ""function""}]";

        var web3 = new Web3("https://mainnet.infura.io/v3/f2f7bb6122414f6e86721e43312d5e0c");

        var contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7"; //USDT contract address
        var contract = web3.Eth.GetContract(contractABI, contractAddress);

        var getTotalSupply = contract.GetFunction("totalSupply");
        var totalSupply = await getTotalSupply.CallAsync<UInt64>();
4

0 回答 0