Generating Go Contracts File

Generate abi and corresponding golang contracts files.

# Compiling the contract and generating abi and bin files
solc --abi --bin Store.sol -o abi
# Generating go contract file
abigen --bin=./abi/Store.bin --abi=./abi/Store.abi --pkg=store --out=Store.go

Store.sol:

pragma solidity ^0.4.24;

contract Store {
  event ItemSet(bytes32 key, bytes32 value);

  string public version;
  mapping (bytes32 => bytes32) public items;

  constructor(string _version) public {
    version = _version;
  }

  function setItem(bytes32 key, bytes32 value) external {
    items[key] = value;
    emit ItemSet(key, value);
  }
  
}

Last updated