diff --git a/docs/developers/dapp-developer/native-bindings-v2.md b/docs/developers/dapp-developer/native-bindings-v2.md index e0fe21286e..eb0f16b836 100644 --- a/docs/developers/dapp-developer/native-bindings-v2.md +++ b/docs/developers/dapp-developer/native-bindings-v2.md @@ -60,42 +60,62 @@ This contract can be pasted into a text file and saved as `Storage.sol`. The following code snippet shows how an ABI can be generated for `Storage.sol` using the Solidity compiler `solc`. ```shell -solc --abi Storage.sol -o build +solc --combined-json abi,bin Storage.sol > Storage.abi ``` The ABI can also be generated in other ways such as using the `compile` commands in development frameworks such as [Foundry](https://book.getfoundry.sh/), [Hardhat](https://hardhat.org/) and [Brownie](https://eth-brownie.readthedocs.io/en/stable/) or in the online IDE [Remix](https://remix.ethereum.org/). ABIs for existing verified contracts can be downloaded from [Etherscan](https://etherscan.io/). -The ABI for `Storage.sol` (`Storage.abi`) looks as follows: +The "combined json" for `Storage.sol` (ABI definition and deployer bytecode in `Storage.abi`) looks as follows: ```json -[ - { - "inputs": [], - "name": "retrieve", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" +{ + "contracts": { + "Storage.sol:Storage": { + "abi": [ + { + "inputs": [], + "name": "retrieve", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "name": "store", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "6080604052348015600e575f5ffd5b506101298061001c5f395ff3fe6080604052348015600e575f5ffd5b50600436106030575f3560e01c80632e64cec11460345780636057361d14604e575b5f5ffd5b603a6066565b60405160459190608d565b60405180910390f35b606460048036038101906060919060cd565b606e565b005b5f5f54905090565b805f8190555050565b5f819050919050565b6087816077565b82525050565b5f602082019050609e5f8301846080565b92915050565b5f5ffd5b60af816077565b811460b8575f5ffd5b50565b5f8135905060c78160a8565b92915050565b5f6020828403121560df5760de60a4565b5b5f60ea8482850160bb565b9150509291505056fea26469706673582212200857cb05506ae0a0b1cb7a5f2c713313775ab4ec0c0c8e02a0d5c9ce9dd77fd364736f6c634300081c0033" + } }, - { - "inputs": [{ "internalType": "uint256", "name": "number", "type": "uint256" }], - "name": "store", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] + "version": "0.8.28+commit.7893614a.Darwin.appleclang" +} ``` The contract binding can then be generated by passing the ABI to `abigen` as follows: ```sh -$ abigen --v2 --abi build/Storage.abi --pkg main --type Storage --out Storage.go +$ abigen --v2 --combined-json build/Storage.abi --pkg main --type Storage --out Storage.go ``` Where the flags are: - `--v2`: Mandatory flag to specify the newest version of the binding generator. -- `--abi`: Mandatory path to the contract ABI to bind to +- `--combined-json`: Mandatory path to the contract combined json (ABI + deployer bytecode) to bind to - `--pkg`: Mandatory Go package name to place the Go code into - `--type`: Optional Go type name to assign to the binding struct - `--out`: Optional output path for the generated Go source file (not set = stdout)