0

I'm encoding parameters on-chain to pass into new OZ Beacon proxy instances. For verification purposes, I need to encode the same arguments via ethers.js

The solidity function:

abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)

And an ethers function that I tried, but returns an undesired result (longer, does not start with function selector)

  const abiCoder = ethers.utils.defaultAbiCoder;
  const encoded = abiCoder.encode(...
2

It would something along the lines of:

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

Note that signature needs to be in the format of function functionName(type1 param1, type2 param2, ...).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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