Created
April 25, 2024 07:30
-
-
Save parv3213/91aabf7164a483c47596ee45eb2b0043 to your computer and use it in GitHub Desktop.
Simple metadata encode decode
This file contains hidden or 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
| 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