Call contract methods with "dynamic-length arrays" arguments
See original GitHub issueHi,
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Smart contract external function with dynamic array of bytes32 ...
I create contract with correct ABI (checked it several times), pass the same arguments to it's function contracts.startNewBallot(). Transaction ...
Read more >Dynamic Arrays and its Operations in Solidity - GeeksforGeeks
The Dynamic arrays are the arrays that are allocated memory at the runtime and the memory is allocated from the heap. ... int[]...
Read more >Limits of Returning Arrays of Dynamic Size in Solidity Smart ...
So, we will research the dependency between gas spent and array size in bytes. We are using uint256[] array for simplicity. For other...
Read more >Failed to call solidity function with array argument
This solution works well, if arguments sizes are known at compile time, but with dynamic sizes this doesn't work. How can I resolve...
Read more >Solidity Tutorial: all about Array | by Jean Cvllr - Medium
Array types · Fixed-size vs dynamic size arrays; One-dimensional vs Multi-Dimensional arrays. · Fixed Size: T[k] · Dynamic Size: T[] · T[k] :...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The way you are trying looks completely fine and I use it al the time.
console.log(emplyeeList)
to see if there are three addresses present or are last two undefined.Hi, @ricmoo yes, it does work. I forgot to reply, sorry. Please close it. Thanks for your help.