question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create utility method for simple selector calculation

See original GitHub issue

With ethereumjs-abi you can do this to obtain the method identifier of some function:

const id = abi.methodID('balanceOf', ['address'])

and this gives you 70a08231.

Is there a way to do this with @ethersproject/abi? I know I can use the abi to create an interface, but in this particular scenario I literally have the name of the function and the list of types of the inputs.

Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
yuetloocommented, Sep 4, 2020
var abi = [ "function balanceOf(address)"]
var iface = new ethers.utils.Interface(abi)
var id = iface.getSighash('balanceOf');
// '0x70a08231'
1reaction
delaaxecommented, Oct 15, 2021

Could this be directly availalable on contract methods? As in:

const Contract = await ethers.getContractFactory("ERC20");
const instance = await Contract.deploy(...);
console.log(instance.balanceOf.getSighash());
// 0x70a08231

I can do a code contribution if you point me in the right directions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Build a Simple Calculator Using HTML, CSS, and ...
Simple, calculated code is the way to go when programming. Check out how to build your own calculator in HTML, CSS, and JS....
Read more >
How to Manually Calculate Partworth Utilities - Conjointly
To calculate level partworths: Step 1: Calculate the average preference across individuals for each level, by averaging the scores in each column. ......
Read more >
Incorporating Utility function in decision making process.
Incorporate the Utility function in your decision-making process using SpiceLogic Decision Maker & Analyzer.
Read more >
Simple comparison polling to create utility functions - EA Forum
It guides individuals through a process of comparing different pairs of items, by asking them, “How much more valuable is the first option ......
Read more >
Conjoint Analysis - Calculations / Methodology - QuestionPro
Utility Value is calculated using part worth value. For every level of attribute summation of part worth is calculated. Then the average of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found