我有一个坚固的功能
function check(IERC20 _token) internal view {...}
我想使用 web3.js 调用该函数
contractInst = new web3.eth.Contract(contractABI);
await contractInst.methods.check(_token ).send({from: await connectedAdd, gas: "2000000"},function(error, transactionHash) {} );
但我不知道如何创建 (IERC20 _token) 变量。
出于 ABI 编码目的,所有接口参数(包括
IERC20
)都会转换为 address
类型。
使用
web3js
,您可以将 Solidity address
作为 JS string
传递。示例:
const _token = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
await contractInst.methods.check(_token ).send(...);