Calling a function with nested structs
See original GitHub issue@ricmoo do you have an example of how to use the new ABI encoder released in Solidity 0.4.19? I’m particularly interested in how to pass in nested structs as a parameter. For example, how to call addTestStruct
in the following example contract using Ethers.js
pragma solidity 0.4.19;
pragma experimental ABIEncoderV2;
contract TestContract
{
struct SubStruct {
uint256 id;
string description;
}
struct TestStruct {
uint256 id;
string description;
SubStruct subStruct1;
}
TestStruct[] public tests;
function addTestStruct(TestStruct testStruct) public
{
tests.push(testStruct);
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (9 by maintainers)
Top Results From Across the Web
Nested Structure in C with Examples - GeeksforGeeks
1. By separate nested structure: In this method, the two structures are created, but the dependent structure(Employee) should be used inside the ...
Read more >C function to modify the value of a nested struct?
The ModifyEngSpeedSampleRate() function above cannot be called with a pointer to the ASREngCtrlActive member because it has the wrong type.
Read more >Nested Structure in C Programming Language Tutorial
In this tutorial, you will learn about Nested Structures in C Programming language.A Structure is a collection of similar elements.
Read more >Nested structure in C - Javatpoint
Just like other variables, a structure can also be passed to a function. We may pass the structure members into the function or...
Read more >Nested Structures in C - C Programming Tutorial - OverIQ.com
Here the first member is of type struct person . If we use this method of creating nested structures then you must first...
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
It doesn’t support named parameter yet (mostly because I haven’t written test cases yet), but you can do this:
It is a very simple change to add names, I just need to make sure it works, so need to test it. After that, you can do:
This is fixed in https://github.com/ethers-io/ethers.js/commit/df930103e75dd89c9f6c14acda857a07f1b0d70c with test cases added for computing method signatures in general.