A Golang client library to communicate with Ethereum and Stellar RPC servers.
- Implements most of JSON-RPC methods and several client-specific methods.
- Provides a high-level interface to propose/get validators on an Istanbul blockchain.
- Provides a high-level interface to create private contracts on a Quorum blockchain.
- Provides a bare bones wrapper to send simple transactions on a Stellar blockchain.
- Provides a generic client interface for all Dial()ed endpoints:
GetInfo()SendAmount(from, to, amount)GetBalance(account)
go get -u github.com/ethereum/go-ethereum
go get -u github.com/getamis/eth-client/
go get -u github.com/stellar/go
go get -u github.com/inconshreveable/log15
package main
import (
"context"
"fmt"
// Generic interface common to all endpoint types
//"github.com/Blockdaemon/node-client-sdk/client"
// Ethereum specific interface
"github.com/Blockdaemon/node-client-sdk/eth"
// Stellar/Horzion specific interface
//"github.com/Blockdaemon/node-client-sdk/stellar"
)
func main() {
// Note that by default, HTTP does not support the mining API
// If mining is not enabled on the node's HTTP endpoint, replace
// with local IPC socket filename
url := "http://127.0.0.1:8545"
client, err := eth.Dial(url)
// For Stellar, something like:
//url := "http://127.0.0.1:8000"
//coreurl := "http://127.0.0.1:11626"
//passphrase := ""
//client, err := stellar.Dial(url, coreurl, passphrase)
if err != nil {
fmt.Println("Failed to dial, url: ", url, ", err: ", err)
return
}
// Should work for all types of Dial()ed endpoints
balance, err := client.GetBalance(context.Background(),
"de155b6f2aead0474c7428424dec755170e97f76")
if err != nil {
fmt.Println("Failed to get balance, err: ", err)
return
}
fmt.Println("balance: ", balance)
// Ethereum specific
err = client.SetMiningAccount(context.Background(),
"de155b6f2aead0474c7428424dec755170e97f76")
if err != nil {
fmt.Println("Failed to set etherbase, err: ", err)
return
}
err = client.StartMining(context.Background())
if err != nil {
fmt.Println("Failed to start mining, err: ", err)
return
}
fmt.Println("start mining")
}- admin_addPeer
- admin_adminPeers
- admin_nodeInfo
- eth_blockNumber
- eth_sendRawTransaction
- eth_getBlockByHash
- eth_getBlockByNumber
- eth_getBlockByHash
- eth_getBlockByNumber
- eth_getTransactionByHash
- eth_getBlockTransactionCountByHash
- eth_getTransactionByBlockHashAndIndex
- eth_getTransactionReceipt
- eth_syncing
- eth_getBalance
- eth_getStorageAt
- eth_getCode
- eth_getBlockTransactionCountByNumber
- eth_call
- eth_gasPrice
- eth_estimateGas
- eth_sendRawTransaction
- miner_setEtherbase
- miner_startMining
- miner_stopMining
- net_version
- supportedModules
- logs
- newHeads
- eth_getLogs
// Package tokenbalance is used to fetch the latest token balance for any Ethereum address and ERC20 token. You can install
// this package/CLI or you can use basic HTTP GET on the public TokenBalance server.
//
// Mainnet API Endpoint:
// https://api.tokenbalance.com
//
// Example: https://api.tokenbalance.com/balance/0xa74476443119A942dE498590Fe1f2454d7D4aC0d/0xda0aed568d9a2dbdcbafc1576fedc633d28eee9a
// Response: 5401731.086778292432427406
//
// Example: https://api.tokenbalance.com/token/0xa74476443119A942dE498590Fe1f2454d7D4aC0d/0xda0aed568d9a2dbdcbafc1576fedc633d28eee9a
// Response:
// // { // "token": "0xa74476443119A942dE498590Fe1f2454d7D4aC0d", // "wallet": "0xda0AEd568D9A2dbDcBAFC1576fedc633d28EEE9a", // "name": "Golem Network token", // "symbol": "GNT", // "balance": "5401731.086778292432427406", // "eth_balance": "0.985735366999999973", // "decimals": 18, // "block": 6461672 // } //
//
// Ropsten Testnet API Endpoint:
// https://test.tokenbalance.com
//
// Rinkeby Testnet API Endpoint:
// https://rinkeby.tokenbalance.com
//
// More info on: https://github.com/hunterlong/tokenbalance
To use these methods, make sure that
- Server is running on Istanbul consensus.
- Connect to server through
istanbul.Dialfunction (not the original Geth client).
Methods:
- istanbul_getValidators
- istanbul_propose
To use these methods, make sure that
- Server is running on Quorum blockchain
- Connect to server through
quorum.Dialfunction (not the original Geth client).
Methods:
- quorum_privateContract
- quorum_contract
To use these methods, make sure that
- Server is running a Stellar blockchain
- Make sure the horizon service is running as well.
- Connect to server through
stellar.Dialfunction. You will need to supply both the core and horizon endpoints, as well as the network passphrase
Methods:
- core.Info
- horizon.SubmitTransaction
- horizon.LoadAccount
Feel free to contribute to this repository.
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request
- https://github.com/ethereum/go-ethereum
- https://github.com/ethereum/wiki/wiki/JSON-RPC
- ethereum/EIPs#650
- https://github.com/jpmorganchase/quorum
- https://github.com/getamis/istanbul-tools
- https://github.com/stellar/go/clients/stellarcore
- https://github.com/stellar/go/clients/horizon
- https://github.com/stellar/go/build