Skip to main content
added 132 characters in body; edited tags
Source Link
Ryan Sea
  • 668
  • 4
  • 20

I need to create an array of structs for a struct that looks like this:

struct myStruct {
   address _address;
   uint _num;
}

And I need to create the array from function args.

I'm doing this by using 2 params (address[] & uint[]) that represent the 2 struct members, and for looping through them to create the array of structs. Is there a simpler way? Potentially using

ethers.utils.AbiCoder.prototype.encode(
  ['address', 'uint'],
  [<address>, <number>]
);

I need to create an array of structs for a struct that looks like this:

struct myStruct {
   address _address;
   uint _num;
}

And I need to create the array from function args.

I'm doing this by using 2 params (address[] & uint[]) that represent the 2 struct members, and for looping through them to create the array of structs. Is there a simpler way?

I need to create an array of structs for a struct that looks like this:

struct myStruct {
   address _address;
   uint _num;
}

And I need to create the array from function args.

I'm doing this by using 2 params (address[] & uint[]) that represent the 2 struct members, and for looping through them to create the array of structs. Is there a simpler way? Potentially using

ethers.utils.AbiCoder.prototype.encode(
  ['address', 'uint'],
  [<address>, <number>]
);
Source Link
Ryan Sea
  • 668
  • 4
  • 20

How to make a mixed-type struct from function args?

I need to create an array of structs for a struct that looks like this:

struct myStruct {
   address _address;
   uint _num;
}

And I need to create the array from function args.

I'm doing this by using 2 params (address[] & uint[]) that represent the 2 struct members, and for looping through them to create the array of structs. Is there a simpler way?