Abi encode/decode not same as solidity encoding #4706
-
Theres a mismatch in bytes encoding between ethers and solidity
But with solidity
calling
So bytes generated from ethers is not being parsed in solidity and vice versa. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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. :) |
Beta Was this translation helpful? Give feedback.
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:
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. :)