Now, with the ABIEncoderV2 enabled you can pass a struct type into a function from web3 or another contract. When compiling a contract with ABIEncoderV2 enabled there are a few changes to the compiled ABI output. The ABI JSON will now include a new type called ‘tuple’ when it comes across structs as parameters in a function. The tuple type is paired with the property ‘components’, the components prop is an array with a list of {name, type} objects.

Below is an example of the ABI of a contract that uses a struct as an input parameter. Notice the type and components properties.

Below is an example storage contract that uses the new encoder

The use of structs in your function parameters can significantly reduce the clutter and complexity of your contracts while enabling them to be much more pleasant to interact with.

Make sure to check out our services and stay in touch.