How do I get all the transaction functions in an ABI? #1468
Answered
by
ricmoo
reddyismav
asked this question in
Q&A
-
So if given an ABI, I need all the functions that result in a transaction. If I remember correctly, in the past, you could NOT specify view on a function, but it wouldn't still result in a transaction. so, excluding view|pure type functions from ABI mightn't be 100% correct. Is there anything I can use for this. |
Beta Was this translation helpful? Give feedback.
Answered by
ricmoo
Apr 14, 2021
Replies: 1 comment 3 replies
-
The easiest is probably: // If you have a Contract object, you can use contract.interface instead of this next line
const iface = new ethers.utils.Interface(abi);
// Filter out the fragments that are functions and not constants
const txFuncs = iface.fragments.filter((f) => (f.type === "function" && !f.constant)); Let me know if that works for you. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ricmoo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The easiest is probably:
Let me know if that works for you.