-
In previous version i can get signature from this method
How can do it in new version? |
Beta Was this translation helpful? Give feedback.
Answered by
ardislu
Mar 13, 2023
Replies: 1 comment 1 reply
-
Get the const abi = [
'function balanceOf(address _owner) external view returns (uint256 balance)',
'function transferFrom(address _from, address _to, uint256 _value) external returns (bool success)',
'function approve(address _spender, uint256 _value) external returns (bool success)',
'function allowance(address _owner, address _spender) external view returns (uint256 remaining)'
];
const interface = new ethers.Interface(abi);
interface.getFunction('balanceOf').selector;
// '0x70a08231'
interface.getFunction('transferFrom').selector;
// '0x23b872dd' You can also directly calculate the keccak256 hash from a string using the ethers.id('balanceOf(address)').substring(0, 10);
// '0x70a08231'
ethers.id('transferFrom(address,address,uint256)').substring(0, 10);
// '0x23b872dd' |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ricmoo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get the
FunctionFragment
object from the interface usinggetFunction
, then call theselector
property. Example:You can also directly calc…