Getting Started With Seele

Setting Up a Node

  • Preparations:

    • Install Go v1.10 or higher, Git, and the C compiler.
    • Clone the go-seele repository to the GOPATH directory : go get -u -v github.com\seeleteam\go-seele\...
    • In $GOPATH\src\github.com\seeleteam\go-seele, build the source: run make all for Linux/Mac and buildall.bat for Windows.
  • In $GOPATH\src\github.com\seeleteam\go-seele\build, you can find an executable node. It is recommended to copy all the node*.json files under

    $GOPATH\src\github.com\seeleteam\go-seele\cmd\node\config\

    to this go-seele\build directory. They are configuration files. But we will assume these node json files are at go-seele\build directory throughout the document.

    • Something you may need to know before running a node:
        1. If you run into the error related to “genesis block hash mismatch”, follow the solution located here.
        1. Unless otherwise stated, the nodes mentioned below refer to the full node.
  • Get an account:

    You will need an account to send transactions, deploy contracts and start mining on the mainnet. See How to create an account to create your own account. However, if you just want to run a seele node locally or in a test environment, you can skip this step. Some default accounts are provided for testing.

  • Running a Node:

    Assume you have copied the node json files to the go-seele/build directory. These are 4 node configurations that can be used as examples. To use your own account to interact with the mainnet, make sure you use the correct coinbase, p2p private key and shard information in one of these json files. For details, see How to customize your node configurations.

    • In go-seele/build:

      • On Windows:
        • Running a Single Node:
          • In the cmd window, run: node start -c node1.json
          • By default this will start the miner. You can add flags -m stop to not start the miner.
        • Running Multiple Nodes:
          • In one cmd window, run: node start -c node1.json
          • In a second cmd window, run: node start -c node2.json
      • On Linux & Mac:
        • Running a Single Node:
          • On terminal, run: ./node start -c node1.json
          • By default this will start the miner. You can add flags -m stop to not start the miner.
        • Running Multiple Nodes:
          • In one terminal window, run: ./node start -c node1.json
          • In another terminal window, run: ./node start -c node2.json

      If you want to have a quickstart in a test or private blockchain environment, you can use the default node configurations and accounts. For example:

      ./node start -c node1.json --accounts $GOPATH/src/github.com/seeleteam/go-seele/cmd/node/config/accounts.json
      

      Note that seeleteam/go-seele/cmd/node/config/accounts.json only contains test accounts, do not use them if you are going to connect to the Seele mainnet.

  • The node configuration and test accounts are shown as follows. To modify it for your own account, see How to customize your node configurations.

node1.json:

{
  "basic":{
    "name": "seele node1",
    "version": "1.0",
    "dataDir": "node1",
    "address": "0.0.0.0:8027",
    "coinbase": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
    "algorithm": "spow"
  },
  "p2p": {
    "privateKey": "0xf65e40c6809643b25ce4df33153da2f3338876f181f83d2281c6ac4a987b1479",
    "staticNodes": [],
    "address": "0.0.0.0:8057",
    "networkID": "seele"
  },
  "log": {
    "isDebug": false,
    "printLog": false
  },
  "httpServer": {
    "address": "0.0.0.0:8037",
    "crossorigins": [
      "*"
    ],
    "whiteHost": [
      "*"
    ]
  },
  "wsserver": {
    "address": "0.0.0.0:8047",
    "crossorigins": [
      "*"
    ]
  },
  "metrics": {
    "address": "0.0.0.0:8087",
    "duration": 10,
    "database": "influxdb",
    "username": "test",
    "password": "test123"
  },
  "genesis": {
    "difficult":20,
    "shard":1,
    "timestamp":1539742676
  }
}

accounts.json:

{
  "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1": 1000000000000,
  "0x0a57a2714e193b7ac50475ce625f2dcfb483d741": 1000000000000,
  "0x2a23825407740fa7163069257c57452c4d4fc3d1": 1000000000000,
  "0x2a87b6504cd00af95a83b9887112016a2a991cf1": 1000000000000,
  "0x3b691130ec4166bfc9ec7240217fc8d08903cf21": 1000000000000,
  "0x4eea165e9266f20bf6e5e08e0c11d38e8fc02661": 1000000000000,
  "0x4fb7c8b0287378f0cf8b5a9262bf3ef7e101f8d1": 1000000000000,
  "0xec759db47a65f6537d630517f6cd3ca39c6f93d1": 1000000000000,
  "0xfaf78f23293cc537154c275c874ede0f8c8b8801": 1000000000000,
  "0xfbe506bdaf256682551873290d0a794d51bac4d1": 1000000000000
}

Domain

Parameter

Explanation

basic

name

Name of node

version

Version of node

dataDir

System file path of node, used to store data

address

Address to start RPC server

coinbase

Coinbase used to mine

algorithm

consensus algorithm of the network

p2p

privateKey

Private key for the p2p module, not used as an account

staticNodes

A static node. When the node is started, it will be connected to search for more nodes.

address

The p2p server will listen on the TCP connection, which is used as the UDP address for the Kad protocol.

networkID

Used to indicate the network type.

log

isDebug

If IsDebug is true, the log will be on the debug level, otherwise it will be on the info level.

printLog

If PrintLog is true, then all logs will be printed on the console, otherwise it will be written and stored in a file.

httpServer

address

HTTP RPC’s service address.

crossorigins

Sent to the client’s cross-origin resource sharing origin. Note that CORS is a type of forced safety measure by the browser, which is irrelevant to the client’s custom HTTP.

whiteHost

Whitelist of permitted hosts.

wsserver

address

Address of Websocket RPC server.

genesis

timestamp

Timestamp of the genesis block.

difficult

Difficulty level: should be easy at the beginning in order for easier block creation.

shard

Shard number of the genesis block.

  • Help:

    Use “node -h” for a list of available commands.

    Use “node [command] –help” for more information about a command.

Create a Full Node Client:

  • Preparations:

    • Install go v1.10 or higher and the C compiler.
    • In seeleteam\go-seele\build
  • Running a Full Node Client:

    • On Windows:
      • In the command window, run: client
    • On Mac & Linux:
      • In the command window, run: ./client
  • By default, client will interact with address 127.0.0.1:8027. To interact with other addresses, you will need to add -a [address] while using client. For example,

    client getbalance --account [certain account address] -a 127.0.0.1:8028

    By default, we use port 8027 for node1.json, port 8028 for node2.json, port 8029 for node3.json, port 8026 for node4.json.

  • Help:

client -h
NAME:
   client - interact with a full node process

USAGE:
   client [global options] command [command options] [arguments...]

AUTHOR:
   seeleteam <dev@seelenet.com>

COMMANDS:
     call              call contract
     deckeyfile        Decrypt key file
     domain            system domain name commands (under development)
     dumpheap          dump heap for profiling, return the file path
     getbalance        get balance info
     getblock          get block by height or hash
     getblockheight    get block height
     getblocktxcount   get block transaction count by block height or block hash
     getdebtbyhash     get debt by debt hash
     getdebts          get pending debts
     getinfo           get node info
     getlogs           get logs
     getnonce          get account nonce
     getpendingtxs     get pending transactions
     getreceipt        get receipt by transaction hash
     getshardnum       get account shard number
     gettxbyhash       get transaction by transaction hash
     gettxinblock      get transaction by block height or block hash with index of the transaction in the block
     gettxpoolcontent  get transaction pool contents
     gettxpoolcount    get transaction pool transaction count
     htlc              Hash time lock contract commands
     key               generate key with or without shard number
     miner             miner commands
     p2p               p2p commands
     payload           generate the payload according to the abi file and method name and args
     savekey           save private key to a keystore file
     sendtx            send transaction to node
     sign              generate a signed transaction and print it out
     subchain          system sub chain commands
     help, h           Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help

Create a Light Node Client:

  • Preparations:

    In seeleteam/go-seele/build/,

    • Install go v1.10 or higher and the C compiler.

    • To run a light node, run

      ./node start -c node1.json -l

      where node1.json can be replaced by other node json files.

  • Running a Light Node Client:

    • On Windows:
      • In the command window, run: light
    • On Mac & Linux:
      • In the command window, run: ./light
  • Help:

light -h
NAME:
   light - interact with a light node process

USAGE:
   light [global options] command [command options] [arguments...]

AUTHOR:
   seeleteam <dev@seelenet.com>

COMMANDS:
     deckeyfile        Decrypt key file
     getbalance        get balance info
     getblock          get block by height or hash
     getblockheight    get block height
     getblocktxcount   get block transaction count by block height or block hash
     getnonce          get account nonce
     getpendingtxs     get pending transactions
     getreceipt        get receipt by transaction hash
     getshardnum       get account shard number
     gettxbyhash       get transaction by transaction hash
     gettxinblock      get transaction by block height or block hash with index of the transaction in the block
     gettxpoolcontent  get transaction pool contents
     gettxpoolcount    get transaction pool transaction count
     key               generate key with or without shard number
     p2p               p2p commands
     payload           generate the payload according to the abi file and method name and args
     savekey           save private key to a keystore file
     sendtx            send transaction to node
     sign              generate a signed transaction and print it out
     help, h           Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help

Some common-used commands:

0. Get an account

1. Transfer

  • You need an account with Seeles to make a transaction.
// Assume you have created your account with address 0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 and the keyfile is .keystore-shard1-0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21

// Request (if not given value,  default value will be : gasprice = 10, gaslimit = 21000)

// In seeleteam\go-seele\cmd\client, run:

client sendtx --amount 10 --price 10 --gas 21000 --from .keystore-shard1-0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 --to 0xb286933bccbec9ca1cd92257d12d12ebab9b1201

// Response

Please input your key file password:
account 0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 current nonce: 0, sending nonce: 0
transaction sent successfully
{
  "Hash": "0x9c0e2565b8a0b33c3f69aa6eb9bad4a86c3925a1fe12272e2082091b9b1c5609",
  "Data": {
      "From": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
      "To": "0xb286933bccbec9ca1cd92257d12d12ebab9b1201",
      "Amount": 10,
      "AccountNonce": 0,
      "GasPrice": 1,
      "GasLimit": 21000,
      "Timestamp": 0,
      "Payload": ""
  },
  "Signature": {
      "Sig": "N8XzJ/GEpU73dpzW5t5WShmVPFb8gQOrInGdypul8aBaDakmhbZ2rdqekA5bWslHQBfsoafeMukF5b7A1/6JWQA="
  }
}
  • Query a transaction with Hash.
// Request
client getreceipt --hash 0x9c0e2565b8a0b33c3f69aa6eb9bad4a86c3925a1fe12272e2082091b9b1c5609

// Resposne
{
  "contract": "0x",
  "failed": false,
  "poststate": "0xef59ced1b06d3ec77aa5c3b0fa1bd7cdd83890961f49d06aabe0a2d57583dd3b",
  "result": "0x",
  "totalFee": 21000,
  "txhash": "0x9c0e2565b8a0b33c3f69aa6eb9bad4a86c3925a1fe12272e2082091b9b1c5609",
  "usedGas": 21000
}

The result of "failure": falserow, indicating that the transaction was successful. If the transaction is not completed, you may see get error when call rpc leveldb: not found. You could use client gettxbyhash to query the transaction status.

  • Confirm the balance of receiver account.
// Request
client getbalance --account 0xb286933bccbec9ca1cd92257d12d12ebab9b1201

// Response
{
      "Account": "0xb286933bccbec9ca1cd92257d12d12ebab9b1201",
      "Balance": 10
}

2. Deploy contract

  • In the following, we demonstrate how to deploy a smart contract on Seele blockchain. Before deploying the smart contract, you will need to compile your Solidity code to bytecode for EVM (Ethereum Virtual Machine) since Seele uses EVM. Currently, we support contracts in Solidity v0.4.25 - v0.5.0. As an example, see simple_storage.sol. Using the contract simulator will help you get the contract Bytecode data (by using Remix) which will be the input of the payload parameter. There is no need to specify the address of the smart contract since the address will be created automatically. The smart contract address can be found in the receipt as introduced in the following step.
  // Request
client sendtx --amount 0 --from .keystore-shard1-0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 --payload 0x608060405234801561001057600080fd5b50600560008190555060df806100276000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a723058207f6dc43a0d648e9f5a0cad5071cde46657de72eb87ab4cded53a7f1090f51e6d0029

  // Response
Please input your key file password:
account 0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 current nonce: 0, sending nonce: 0
transaction sent successfully
{
    "Hash": "0xc4674bf0a3ee0796d3ae139ac40a480fa40d4e59ed0af9aa22d57dbc3c21a96e",
    "Data": {
        "From": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
        "To": "0x0000000000000000000000000000000000000000",
        "Amount": 0,
        "AccountNonce": 0,
        "GasPrice": 10,
        "GasLimit": 200000,
        "Timestamp": 0,
        "Payload": "0x608060405234801561001057600080fd5b50600560008190555060df806100276000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a723058207f6dc43a0d648e9f5a0cad5071cde46657de72eb87ab4cded53a7f1090f51e6d0029"
    },
    "Signature": {
        "Sig": "Ws2zZlCiAyZYIx/iQQwz7hAG+K99gR5B8db2GZ0zKW8hTUfSBt1XH3swcB+dtZR/yUC1tl+jRY3Jv6fwRtYiiwA="
    }
}
  • Query the contract deployment result
// Request
client getreceipt --hash 0xc4674bf0a3ee0796d3ae139ac40a480fa40d4e59ed0af9aa22d57dbc3c21a96e

// Response
{
    "contract": "0x12fe58608430e36ba6bfb0a9bc5623a634530002",
    "failed": false,
    "poststate": "0x6bccb0ae94795ae716644300257863e157dd5717a00ca3293bd1d7e0cc1ece61",
    "result": "0x6080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a723058207f6dc43a0d648e9f5a0cad5071cde46657de72eb87ab4cded53a7f1090f51e6d0029",
    "totalFee": 1007070,
    "txhash": "0xc4674bf0a3ee0796d3ae139ac40a480fa40d4e59ed0af9aa22d57dbc3c21a96e",
    "usedGas": 100707
}

The result of "failure": falserow, which indicates the deployment of the contract was successful. The result of "contract": "0x12fe58608430e36ba6bfb0a9bc5623a634530002" row is the contract address.

3. Call contract

Sendtx

  • After you successfully deploy your contract on Seele, the contract has its own address. To call the contract, you will need to send a transaction to the contract address. Using the contract simulator will help you prepare the transaction payload (by using Remix).
 // Request
 client sendtx --amount 0   --payload 0x6d4ce63c --from .keystore-shard1-0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 --to 0x12fe58608430e36ba6bfb0a9bc5623a634530002

 // Response
 Please input your key file password:
 account 0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21 current nonce: 1, sending nonce: 1
transaction sent successfully
{
   "Hash": "0xae073c03abc04ad182792bc5bf9faeb04d1c80888c985e839f896fd5fd08bf9f",
   "Data": {
       "From": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
       "To": "0x12fe58608430e36ba6bfb0a9bc5623a634530002",
       "Amount": 0,
       "AccountNonce": 1,
       "GasPrice": 10,
       "GasLimit": 200000,
       "Timestamp": 0,
       "Payload": "0x6d4ce63c"
   },
   "Signature": {
       "Sig": "RB7a0T8ej34R7co1OgRsdYh3we1DQmJ1INUq1Tysoi4Sgf89u0Njvld+wOh1+XARhc/ojM4B0rpP4dIqqg7rvAA="
   }
}
  • Query the result
// Request
client getreceipt --hash 0xae073c03abc04ad182792bc5bf9faeb04d1c80888c985e839f896fd5fd08bf9f

// Response
{
  "contract": "0x",
  "failed": false,
  "poststate": "0x0685695c28fde434c3d9b1e857849ad761cc607a804aa32bef4185469c359995",
  "result": "0x0000000000000000000000000000000000000000000000000000000000000005",
  "totalFee": 216960,
  "txhash": "0xae073c03abc04ad182792bc5bf9faeb04d1c80888c985e839f896fd5fd08bf9f",
  "usedGas": 21696
}

Call

  • call the contract, the call command is separate from the blockchain and is suitable for querying data without changing the state.
  // Request
  client call --payload 0x6d4ce63c --to 0x12fe58608430e36ba6bfb0a9bc5623a634530002 --height -1

  // Response
  {
    "contract": "0x",
    "failed": false,
    "poststate": "0x6c81260cea77c64aa240534c27a3c46cf41749f4c027546675819b3b1fb58ccb",
    "result": "0x0000000000000000000000000000000000000000000000000000000000000005",
    "totalFee": 21696,
    "txhash": "0x452c1bbd09292411095780badf8f2b18b5e7ba72910214e683d741ff3547df3e",
    "usedGas": 21696
}

How to customize your node configurations

Under seeleteam/go-seele/cmd/node/config, you can find four node*.json files. You can create your own Seele node by customizing any one of them.

  1. After creating your account (How to create an account), replace “coinbase” field with your public key.
  2. Modify the “shard” field with the correct shard number associated with your account.
  3. Create another private-public key pair. Replace “privateKey” field in “p2p” section with your private key. This private key is used for p2p network only and should be different from the private key you use to mine and send transactions. Do not use private keys associated with your coinbase or any other transaction accounts here!
  4. You could connect to some static nodes in the network by configuration. The format of “staticNodes” field is [“ip:port”,…], for example, [“127.0.0.1:8057”]. The static nodes used to connect to the Seele mainnet can be found on Seele Scan and in node json files under seeleteam/go-seele/cmd/node/config. The ports for shard1, shard2, shard3 and shard4 are 8057, 8058, 8059, 8056 respectively. If you find a node on Seele Scan with different port, try to modify it with the correct ports.
  5. If “isDebug” and “printLog” fields are true, the display is in debug mode and log mode when you run the Seele node. The default value of “isDebug” is false. The default value of “printLog” is true. If “printLog” is false, you will not see the mining details on the screen.
  6. The values of “networkID”, “difficult” and “timestamp” should not be modified. Otherwise your node cannot connect to the mainnet.

GCC install newbie guide

Install Document: https://gcc.gnu.org/install/

Download Link: https://gcc.gnu.org/install/binaries.html

Or you can go directly to the website to download the release installer. (Recommended)

Q&A

genesis block hash mismatch

If the log looks like the following:

  • Windows:
data folder: C:\Users\seele\.seele\node1
INFO[0000] NewSeeleService BlockChain datadir is C:\Users\seele\.seele\node1\db\blockchain  caller="seeleservice.go:62" module=seele
INFO[0000] NewSeeleService account state datadir is C:\Users\seele\.seele\node1\db\accountState  caller="seeleservice.go:72" module=seele
ERRO[0000] NewSeeleService genesis.Initialize err. genesis block hash mismatch  caller="seeleservice.go:88" module=seele
genesis block hash mismatch
  • Linux:
log folder: /var/folders/dq/mcz24sr571g48wrbjvdbpndw0000gn/T/seeleTemp/log
data folder: /Home/seele/.seele/node1
INFO[0000] NewSeeleService BlockChain datadir is /Home/seele/.seele/node1/db/blockchain  caller="seeleservice.go:62" module=seele
INFO[0000] NewSeeleService account state datadir is /Home/seele/.seele/node1/db/accountState  caller="seeleservice.go:72" module=seele
ERRO[0000] NewSeeleService genesis.Initialize err. genesis block hash mismatch  caller="seeleservice.go:88" module=seele
genesis block hash mismatch

You can just delete the .seele/node1 folder and restart. The absolute path to the .seele folder is in the logs printed above.