10

I came across the following code and found the term "pragma experimental ABIEncoderV2". Can anybody be specific in telling what this actually means?

//pragma solidity ^0.5.2;
pragma experimental ABIEncoderV2;
contract test {

struct document{
   string ipfsHash;
   string documentName;
   bytes32 accessKey;
}

struct grantAccess{
   address owner;
   address single;     
}

This is a part of the code I found over the web.

Sourav Kumar
  • 125
  • 1
  • 2
  • 9

2 Answers2

14

Solidity v0.4-v0.7

The standard ABI coder does not allow arrays of dynamic types, structs or nested variables between the Solidity contract and the dApp.

The ABI v2 coder; which allows structs, nested and dynamic variables to be passed into functions, returned from functions and emitted by events.

Note: Do not use experimental features on live deployments.

Solidity v0.8 and above

As per the list of v0.8 breaking changes, the ABIEncoderV2 is not experimental anymore - it is actually enabled by default by the compiler.

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
Mahesh Rajput
  • 1,211
  • 7
  • 17
  • 7
    Wow. Solidity v0.8.0 has JUST BEEN RELEASED WITH ABI coder v2 activated by default!!! – Russo Dec 24 '20 at 10:03
9

From the Solidity v0.8.0 Breaking Changes documentation:

ABI coder v2 is activated by default.

So it is not experimental anymore, but a standard feature since Solidity v0.8.0.

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
Paul Verest
  • 561
  • 1
  • 6
  • 14