Skip to content

How to encode structs with a user defined type? #1301

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

You must be logged in to vote

The ABI coder takes in the same format that the Solidity copier spits out in the ABI, so you can just copy it from there.

Here is what your examples would need:

ethers.utils.defaultAbiCoder.encode(
        [ 'address',
          {
            type: "tuple[]",
            name: "orders",
            components: [
              { name: "makerAddress", type: 'address' },
              { name: "takerAddress", type: 'address' },
              { name: "feeRecipientAddress", type:'address' },
              { name: "senderAddress", type:'address' },

              { name: "makerAssetAmount", type:'uint256' },
              { name: "takerAssetAmount", type:'uint256' },
              { name: "maker…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Whytecrowe
Comment options

@ricmoo
Comment options

@Whytecrowe
Comment options

@ricmoo
Comment options

@Whytecrowe
Comment options

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

This discussion was converted from issue #1300 on February 17, 2021 01:55.