Last active
May 20, 2023 06:21
-
-
Save imewish/fc5ef366753db486d4bd22fdb9ea57f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// json | |
const ethers = require('ethers'); | |
const { FormatTypes } = require('ethers/lib/utils'); | |
const iface = new ethers.utils.Interface([ | |
'event MyEvent(address recipient, address asset, uint256 amount)', | |
]); | |
jsonAbi = iface.format(FormatTypes.json); | |
console.log(JSON.stringify(JSON.parse(jsonAbi), null, 2)); | |
// human readable | |
const {ethers} = require('ethers'); | |
const { Interface, FormatTypes } = require('ethers/lib/utils'); | |
let abi = [...] | |
// create the Ethers.js Interface used for translation, | |
// and pass only the desired ABI content | |
const iface = new Interface(abi); | |
// perform the translation | |
const formattedAbi = iface.format(FormatTypes.full); | |
// const translatedAbi = JSON.stringify(JSON.parse(formattedAbi)); | |
console.log(formattedAbi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment