Git Product home page Git Product logo

simple-go-ethereum's Introduction

Simple Go Ethereum - Smart Contract

Interact to smart contract on Ropsten Test Network Ethereum using Golang

Documents: https://goethereumbook.org/en/smart-contracts/

If you're interested in NodeJS connecting to Ethereum, please reference my simple-node-ethereum here: https://github.com/huynhsamha/simple-node-ethereum

Set up accounts

Create accounts and deposit ether with MetaMask

  • Install extension MetaMask in Chrome browser.
  • Choose Ropsten Test Network.
  • Create accounts and deposit Ether from Test Faucet
  • Get private keys from accounts (MetaMask requires your password)

Create an account with Infura

Create account on https://infura.io

Set up GOPATH

Clone and add this repository path to your GOPATH.

Example, in ~/.bashrc or ~/.zshrc, add the following lines:

export GOPATH=$HOME/go

export GOPATH=$GOPATH:$HOME/Documents/simple-go-ethereum

export PATH=$PATH:$GOPATH/bin

Install go-ethereum

go get github.com/ethereum/go-ethereum

Install smart contract compiler

https://goethereumbook.org/en/smart-contract-compile/

Install solidity compiler (solc)

Compile .sol file to .abi and .bin file

solc --abi Store.sol -o build
solc --bin Store.sol -o build

Install abigen tool (abigen)

Compile .bin and .abi files to .go file

Install bla bla ...

# if get error: abigen command not found
sudo ln -s $HOME/go/bin/abigen /usr/local/bin/abigen

# generate go file
abigen --bin=./build/Store.bin --abi=./build/Store.abi --pkg=store --out=Store.go

Interact to smart contract by Golang

Deploy, load, read and write transaction to smart contract using Go.

https://goethereumbook.org/en/smart-contracts/

Ropsten Etherscan Urls:

Public address: https://ropsten.etherscan.io/address/0x9338063cd5c8f069334925345fadc94a8e45742f

Smart contract address: https://ropsten.etherscan.io/address/0x71733bc1d86F5de7bCBf0587502bB1BeE176E788

Transaction deploying contract: https://ropsten.etherscan.io/tx/0xa3a15b34944525039873f8a8c30d99802690a5f78ddb3609136d9fe1eae0e2b9

Transaction written to contract: https://ropsten.etherscan.io/tx/0x2366ee7e67753a3f60dfd5917dd0a79c3f56a953922d804b402e4404bd4fbc48

simple-go-ethereum's People

Contributors

huynhsamha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.