Getting Started

Set Up a Node

Please see here for how to set up a SCDO node. You can use a SCDO node to join the SCDO mainnet. With a SCDO node, you are able to generate blocks for the SCDO mainnet and mine SCDO tokens. Or you can simply synchronize the data of SCDO mainnet without mining.

Create a Client Executable

A client executable can be downloaded directly from download page. It's a tool for users to quickly interact with SCDO nodes. You can also find this executable in the go-scdo/build directory after you compile go-scdo. Please see here for a complete client command list.

Some Commonly Used Commands With Client:

0. Create an account

You can use

$client key --shard 1

to create an address in shard 1 with corresponding private key. An example of the result is

Account:  1S016776478e64efb72058ac219be0d5b29af402f1
Private key: 0x5ab95091c33c6638c00dff3f1b1b42c5c6936cf9adaefa374aad586d834d6817

Since SCDO mainnet has 4 shards, you can generate accounts from shard 1 to shard 4 by modifying the shard parameter. Also see here for more details.

1. Create a keystore file

After creating your account, you can store your private key in a keystore file which can be used to sign your transactions. For example, use

$client savekey --privatekey 0x5ab95091c33c6638c00dff3f1b1b42c5c6936cf9adaefa374aad586d834d6817 --file mykeyfile --shard 1

to save the private key in mykeyfile. You will be asked to type in a password for using this keystore file.

2. Send a transaction

The following is an example of how to send transaction to a SCDO node via client:

  $client sendtx --from mykeyfile --to 1S01bf3bbed9c2c68c40649b388bd560f9fdaba531 --shard 1 --amount 10000 --price 1 -a 127.0.0.1:8027

Note: The shard parameter indicates the shard of the sender. The -a flag indicates the ip address and port of the SCDO node you are sending transaction to. In this example, 127.0.0.1 is your local address. There should be a local SCDO node running so that the transaction is sent successfully.

You will be asked to type in your key file password:

  Please input your key file password:

Then, a result similar to the following should be displayed:

  sendtx without setting nonce, GetAccountNonce 0
  account: 1S01882c5dadddee6f6ecee47e9408044d69a38de1, transaction nonce: 0
  transaction sent successfully
  {
    "Hash": "0x9c0e2565b8a0b33c3f69aa6eb9bad4a86c3925a1fe12272e2082091b9b1c5609",
    "Data": {
        "From": "1S01882c5dadddee6f6ecee47e9408044d69a38de1",
        "To": "1S01bf3bbed9c2c68c40649b388bd560f9fdaba531",
        "Amount": 10000,
        "AccountNonce": 0,
        "GasPrice": 1,
        "GasLimit": 21000,
        "Timestamp": 0,
        "Payload": ""
    },
    "Signature": {
        "Sig": "N8XzJ/GEpU73dpzW5t5WShmVPFb8gQOrInGdypul8aBaDakmhbZ2rdqekA5bWslHQBfsoafeMukF5b7A1/6JWQA="
    }
  }

To check the transfer result with the tx hash, use

  $client getreceipt --hash 0x9c0e2565b8a0b33c3f69aa6eb9bad4a86c3925a1fe12272e2082091b9b1c5609 -a 127.0.0.1:8027

A response is returned:

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

The result of "failure": falserow, indicating that the transfer was successful. By the way, if tx is not packed by the miner or the miner is packing, you may seeget error when call rpc leveldb: not found. Don't worry, just wait for a few seconds, or you can use client gettxbyhash to check the transaction status.

To check the account balance, use

  $client getbalance --account 1S01882c5dadddee6f6ecee47e9408044d69a38de1 -a 127.0.0.1:8027

A response is displayed:

  // Response
  {
        "Account": "1S01882c5dadddee6f6ecee47e9408044d69a38de1",
        "Balance": 10
  }

Note: To send multiple transactions using client, it is recommended to confirm the last transaction in block before sending the next one. If the last transaction is still pending, the next transaction may be rejected by the transaction pool. A workaround is to increase the nonces of the transactions to let all the transactions enter the transaction pool. But there is a chance that the transactions with smaller nonces cannot be packed because the transactions with larger nonces are packed first.

3. Deploy and call contracts

Please see here.

4. Check the information of a node

The client provides a command for you to check the information of a node quickly. For example, use

$client getinfo -a 127.0.0.1:8027

to check the status of your local node. The string after "-a" indicates the ip and port of the node that you want to check. In this example, we assume you have a local node running and the port is 8027. The outcome will be like

    {
        "BlockAge": 23,
        "Coinbase": "1S011c9dab11f953875fafc374a641bdaf58488771",
        "CurrentBlockHeight": 3339035,
        "HeaderHash": "0x53edbf3f80e3ffeefcb28cf6070939df7ea46926e94502f5e60a96e7459790b0",
        "MinerStatus": "Running",
        "PeerCnt": "10 (3 3 1 3)",
        "Shard": 1,
        "Version": "Scdo_V1.0.0"
    }

See here for more details.

Last updated