Solidity Metadata Format
Solidity compatible metadata is generated by building a Solidity ABI compatible ink! contract using
$ cargo contract build ---metadata solidity
This generates 2 metadata files in your contract's target directory:
<contract-name>.abi
: follows the Solidity ABI JSON format for describing a contract's interface. It's used by tools for contract interaction (e.g. ethers.js)<contract-name>.json
: follows the Solidity contract metadata specification. It's used for reproducible builds/compilation and verification of deployed contracts (e.g. by block explorers and contract verification tools).
Generating Solidity metadata is only possible if all constructor and message arguments and return types can be mapped to equivalent Solidity ABI types (more details here).
<contract-name>.abi
The generated <contract-name>.abi
file follows the Solidity ABI JSON format.
A notable distinction is that while ink! contracts can have multiple constructors,
the Solidity ABI JSON format only allows one, therefore the constructor annotated with
a #[default]
attribute is used.
<contract-name>.json
The generated <contract-name>.json
file follows the Solidity contract metadata specification
with the exception being that we repurpose the "settings"
key to include ink! contract and build info
namespaced under a "settings.ink"
key:
settings.ink
It consists of the following required keys:
hash
: The hash of the contract's binary. (The same content assource.hash
in ink! metadata format).build_info
: Extra information about the environment in which the contract was built. (The same content assource.build_info
in ink! metadata format).
It may optionally include the following key:
image
: If the contract is meant to be verifiable, then the Docker image is specified. (The same content asimage
in ink! metadata format, which is used for verifiable builds).
The ABI JSON content (i.e. the content of the <contract-name>.abi
file) is also contained
in the <contract-name>.json
metadata file under the "output.abi"
key.
MetaMask Compatibility
This section has not yet been written for ink! v6.
TODO @davidsemakula