Skip to content

Instantly share code, notes, and snippets.

@qbig
Created November 5, 2018 05:26
Show Gist options
  • Select an option

  • Save qbig/67cf9743a61fbebda392e0e116790529 to your computer and use it in GitHub Desktop.

Select an option

Save qbig/67cf9743a61fbebda392e0e116790529 to your computer and use it in GitHub Desktop.
Generate solidity smart contract golang binding with go-ethereum devtool

Commands

go get -u github.com/ethereum/go-ethereum
cd $GOPATH/src/github.com/ethereum/go-ethereum/
make
make devtools

solc --abi Store.sol
solc --bin Store.sol
abigen --bin=Store_sol_Store.bin --abi=Store_sol_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);
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment