Skip to content

Abi encode/decode not same as solidity encoding #4706

Answered by ricmoo
nischitpra asked this question in Q&A
Discussion options

You must be logged in to vote

In your example, you are not encoding a struct, you are encoding 3 item, a string, a uint16, and an address.

You should be able to use:

new ethers.AbiCoder().encode([ "(string, uint16, address)"], [ ["hello world",1,"0xAc7072288Bc5000EA06d06A166C85a4D1D7f8D45"] ])

I think that should work; but typing on my phone so may be a typo. Busy basically you need to define the struct shape as the first type and then pass in the values as the first item in the array of things to encode.

Let me know if that works. :)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ricmoo
Comment options

@nischitpra
Comment options

Answer selected by ricmoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants