审批完成后,我想知道如何以json-rpc方式获得当前的批准津贴(从地址到指定的合同和网关)。例如,像eth_call?
调用的to
字段是令牌合约,data
参数是allowance()
函数的abi编码签名,后面跟着它的参数。Eth_call还需要指定在哪个块请求数据-您可以使用& latest"当前块的值
curl -X POST
--url "<your_node_url>"
--data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xdAC17F958D2ee523a2206206994597C13D831ec7","data":"0xdd62ed3e00000000000000000000000086987cca9f86da6b4d8a805c1ebd4130ae120a24000000000000000000000000b2723beacce4bc54f23544343927f048cef6bd5a"}, "latest"],"id":1}'
文档:https://ethereum.org/en/developers/docs/apis/json-rpc/eth_call
我使用这个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);