Skip to content

Instantly share code, notes, and snippets.

@parv3213
Created April 25, 2024 07:30
Show Gist options
  • Select an option

  • Save parv3213/91aabf7164a483c47596ee45eb2b0043 to your computer and use it in GitHub Desktop.

Select an option

Save parv3213/91aabf7164a483c47596ee45eb2b0043 to your computer and use it in GitHub Desktop.
Simple metadata encode decode
import { ethers } from 'hardhat'
async function main() {
const abiCoder = ethers.AbiCoder.defaultAbiCoder()
const a = abiCoder.encode(
['string'],
[
JSON.stringify({
name: 'A-valid-TeamName',
}),
],
)
console.log(a)
const b = abiCoder.decode(['string'], a)
console.log(b)
console.log(JSON.parse(b[0]))
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment