Skip to content

how can get getSighash in v6 #3893

Answered by ardislu
Cazs03 asked this question in Q&A
Mar 12, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Get the FunctionFragment object from the interface using getFunction, then call the selector property. Example:

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 calc…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ricmoo
Comment options

Answer selected by ricmoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants