I found this example code for how to execute abi.encodeWithSignature(...) but in ethers js instead of solidity:

let ABI = [signature];
let iface = new ethers.utils.Interface(ABI);
iface.encodeFunctionData(functionName, [param1, param2, ...]);

source: etherjs equivalent of abi.encodeWithSignature

However this is for versions prior to V6 of ethers. What's the new format for V6?

1 Answer 1


I think this could work. Define interface object like this:

const ifaceERC20 = new ethers.Interface([
  "function approve(address spender, uint256 amount)",
  "function transfer(address to, uint256 amount)"

Then you can do something like the following:

tokenApproveCall = ifaceERC20.encodeFunctionData("approve", [SpenderContractAddress, 1000])

It does not change too much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.