simolus3 / web3dart

Ethereum library, written in Dart.
MIT License
441 stars 270 forks source link

Support for struct type defined in contract? #203

Closed cryptobys-rami closed 2 years ago

cryptobys-rami commented 2 years ago

Hi - Can I pass a struct (which I've defined in my contract) as an argument to a function call to my contract from my flutter app?

simolus3 commented 2 years ago

This is not currently supported by the generator, but you could pass the struct as a list of elements I think.

cryptobys-rami commented 2 years ago

I wonder whether lists in dart and structs in solidity are serialised the same way?

simolus3 commented 2 years ago

They should be. In the solidity ABI, structs are described as tuples which web3dart maps to Dart lists.

cryptobys-rami commented 2 years ago

I can confirm I've managed to pass as a list as you suggested - thank you.

One issue I'm struggling with is that im making contract calls which should revert (I know that because they revert on my JS script) - however from my flutter app all I get back is the transaction hash. Is it the case that there's no support for this in the library? or do I just not know how to find it? Basically they are require statements in my contract which should fail due to the arguments I'm sending across (they fail through my JS test script). Thanks.

cryptobys-rami commented 2 years ago

For good order, ill close this issue as the original issue is solved. Also good to know that I've managed to verify a signature signed off chain, passed into my flutter app, and submitted to the contract for verification. Wouldn't have worked unless the data matched perfectly.