简体   繁体   English

如何在以太坊中获得当前的批准津贴

[英]How to get current approval allowance in Ethereum

After one approve is made, I want to know how to get current approval allowance(from an address, to a specified contract and gateway), in json-rpc way.一次批准后,我想知道如何以 json-rpc 的方式获得当前的批准津贴(从地址,到指定的合同和网关)。 eg like eth_call?例如像eth_call?

The to field of the call is the token contract, and the data param is ABI-encoded signature of allowance() function followed by its arguments.调用的to字段是代币合约, data参数是 ABI 编码的allowance()函数签名,后跟其参数。 eth_call also requires to specify at which block you're requesting the data - you can use the "latest" value for the current block eth_call还需要指定您在哪个块请求数据 - 您可以使用当前块的“最新”值

curl -X POST \
--url "<your_node_url>" \
--data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xdAC17F958D2ee523a2206206994597C13D831ec7","data":"0xdd62ed3e00000000000000000000000086987cca9f86da6b4d8a805c1ebd4130ae120a24000000000000000000000000b2723beacce4bc54f23544343927f048cef6bd5a"}, "latest"],"id":1}'

Docs:https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call文档:https ://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call


I used this JS snippet to build the data param value:我使用这个 JS 片段来构建data参数值:

const data = web3.eth.abi.encodeFunctionCall({
    name: 'allowance',
    type: 'function',
    inputs: [{
        type: 'address',
        name: 'from'
    },{
        type: 'address',
        name: 'to'
    }]
}, [
    "0x86987cca9f86da6b4d8a805c1ebd4130ae120a24",
    "0xB2723BEacce4BC54F23544343927f048CeF6bD5A"
]);
console.log(data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM