Phoenix Chain SDK Doc
  • Introduction
  • Client
    • Initializing a Client
  • Accounts
    • Querying Balances
  • Blocks and Transactions
    • Querying Blocks
    • Querying Transactions
  • Smart Contracts
    • Installing Dev Tools
    • Generating Go Contracts File
    • Deploying Contracts
    • Querying Contracts
    • Writing to Contracts
  • Event logs
    • Filtering Event logs
    • Subscribing to Event Logs
Powered by GitBook
On this page
  1. Smart Contracts

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);
  }
  
}
PreviousInstalling Dev ToolsNextDeploying Contracts

Last updated 2 years ago