Ethers.js: Call contract methods with "dynamic-length arrays" arguments

Created on 30 Oct 2020  路  5Comments  路  Source: ethers-io/ethers.js

Hi,

Could you please let me know how I can call contract methods with "dynamic-length arrays" arguments. I have read this document: Write Methods, and it is quite brief.
Codility function example:
function paySalary(address[] employeeList) public payable {}

In Javascript, I have tried many things including passing an array:
let emplyeeList = [addr_John, addr_Mark, addr_Steve]; await myDapp.paySalary(emplyeeList, overrides);
But it seems it does not work. In the smart contractpaySalary(address[] employeeList), it only takes the first element(length is 1).
Could you please share some insights. Thanks for your great help.

B.R
Andy

discussion

Most helpful comment

The way you are trying looks completely fine and I use it al the time.

  1. Can you console.log(emplyeeList) to see if there are three addresses present or are last two undefined.
  2. Is possible that you can use latest versions of Solidity (v0.7) and ethers js (v5)? I can confirm that the way your using works fine in latest versions, maybe some bugs in older versions which may got fixed.
  3. If you really need to stick to those versions, can you list the versions you are using.

All 5 comments

The way you are trying looks completely fine and I use it al the time.

  1. Can you console.log(emplyeeList) to see if there are three addresses present or are last two undefined.
  2. Is possible that you can use latest versions of Solidity (v0.7) and ethers js (v5)? I can confirm that the way your using works fine in latest versions, maybe some bugs in older versions which may got fixed.
  3. If you really need to stick to those versions, can you list the versions you are using.

Thanks @zemse
I will try that ASAP. Thanks for your great help.

Did that work for you? If so, I'll close this issue.

Hi, @ricmoo
yes, it does work. I forgot to reply, sorry.
Please close it.
Thanks for your help.

Awesome! Thanks. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Levino picture Levino  路  35Comments

elenadimitrova picture elenadimitrova  路  28Comments

pkieltyka picture pkieltyka  路  36Comments

pointtoken picture pointtoken  路  24Comments

Tomix3D picture Tomix3D  路  39Comments