Client

Please see here for downloading or creating a SCDO client.

Command Line Options

Full Node Client

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

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

COMMANDS:
     call              call contract
     deckeyfile        Decrypt key file
     domain            system domain name commands(in 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
     getblocktx        get transaction by block height or block hash
     getblocktxbyhash  get the transactions by block hash
     getblocktxbyheight get the transactions by block height
     getblocktxcount   get block transaction count by block height or block hash
     getchangedaccounts get accounts that are modified
     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
     getscdoforkheight get Scdo fork height
     getshardnum       get account shard number
     gettxbyhash       get transaction by transaction hash
     gettxfromaccount  get transaction from one account at specific height or blockhash
     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
     gettxtoaccount    get transaction to one account at specific height or blockhash
     htlc              Hash time lock contract commands(in development)
     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(in development)
     help, h           Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help

Light Node Client

Client Command List

Call

This method is used to call the functions of a contract. The functions to be called should not alter the state of the contract. If the functions can alter the state of the contract, you should use sendtx instead of call. Please see how to develop and deploy contracts on SCDO for more details.

Type

Template

Console

client call --address <string> --payload <string> --to <string> --height <int>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • height:int64 - block height (default: -1, indicating the most recent block height); if the height is 10000, then the functions of the contract are called based on the contract state at height 10000

  • payload:string - bytecodes containing information of which function to call and function inputs

  • to:string - contract address

Returns

  • contract:string - contract address

  • failed:bool - contract executes successfully or not

  • poststate:string - state trie root hash after transaction execution

  • result:string - transaction result

  • totalFee:int64 - transaction fee

  • txhash:string - transaction hash

  • usedGas:int64 - transaction gas

Example

When using the example below, the contract must be deployed first. The solidity code file:

As you can see, the example is testing the get function.

Deckeyfile

This method is used to decode the keystore file to account address and private key. You will be asked to type in the password of the keystore file.

Type

Template

Console

client deckeyfile --file <string>

Parameters

  • file:string keystore file

Returns

  • Account:string - account address

  • Private key:string - private key

Example

GetBalance

This method returns the balance of the given account.

Type

Template

Console

client getbalance --account <string> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • account:string - account address

  • hash:string - hash value in hex

  • height:int64 - block height or current block height for negative value (default: -1)

Returns

  • Account:string - account

  • Balance:big.Int - account balance

Example

GetBlock

This method is used to obtain the block content of given block height or block hash.

Type

Template

Console

client getblock --height -1 --hash <string>(--height <int>) --fulltx=true --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - block hash

  • height:string - block height

  • fulltx:bool - whether to include detailed transaction information; can use -f instead of --fulltx

Returns

  • debts:array - debts in block

  • Hash:string - debts hash

  • Data:json - debts data

  • TxHash:string - txhash in debt

  • Shard:int - shard number of SCDO node where debts on

  • Account:array - debt account

  • Amount:int64 - debt amount

  • Fee:int64 - debt fee

  • Code:string - debt code

  • hash:string - block hash

  • header:json - block header

  • CreateTimestamp:uint64 - create timestamp

  • Creator:string - creator address

  • DebtHash:string - debts hash

  • Difficulty:big.Int - block difficulty

  • ExtraData:string - extra data

  • Height:unit64 - block height

  • Nonce:unit64 - block nonce

  • PreviousBlockHash:string - previous block hash

  • ReceiptHash:string - Receipts hash

  • stateHash:string - state tree hash

  • TxDebtHash:string - debts hash

  • TxHash:string - tx hash

  • totalDifficulty:big.Int - total difficulty

  • transactions:array - transaction array

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • hash:string - transaction hash

  • payload:array - transaction payload

  • timestamp:big.Int - timestamp

  • to:string - transaction receiver

  • txDebts:array - transaction debts

  • Data:json - txDebts data

  • Account:string - transaction account

  • Amount:int - transaction amount

  • Code:string - transaction code

  • Fee:int - transaction fee

  • Shard:int - transaction shard number

  • TxHash:string - transaction hash

  • Hash:string - txDebts hash

Example

GetBlockHeight

This method is used to obtain the height of the blockchain.

Type

Template

Console

client getblockheight --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:uint64 - current block height

Example

GetBlockTx

This method is used to obtain the transactions in the block of given block height or block hash.

Type

Template

Console

client getblocktx --height -1 --hash <string>(--height <int>) --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - block hash

  • height:string - block height

Returns

  • result: transaction array

Example

GetBlockTxByHash

Similar to GetBlockTx.

GetBlockTxByHeight

Similar to GetBlockTx.

GetBlockTxCount

This method is used to obtain the number of transactions in the block based on block height or hash.

Type

Template

Console

client getblocktxcount --height -1 --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - hash value in hex

  • height:int64 - block height (default: -1)

Returns

  • result:int - number of transaction

Example

GetChangedAccounts

This method is used to obtain the accounts that have a change of status in the block of given block height or block hash

Type

Template

Console

client getchangedaccounts --hash <string> (--height <int>) --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - block hash value in hex

  • height:int64 - block height

Returns

  • account count:int64 - the count of the changed accounts

  • accounts:array - a list of the changed accounts

  • blockHash:string - block hash

Example

GetDebtByHash

This method is used to obtain the content of a debt based on its hash.

Type

Template

Console

client getdebtbyhash --hash <string> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - hash value in hex

Returns

  • blockHash:string - block hash of the block that includes the debt

  • blockHeight:int64 - block height of the block that includes the debt

  • debt:json - debt json

  • Data:json - debt data

  • Account:string - debt account

  • Amount:int64 - debt amount

  • Code:string - debt code

  • Fee:int64 - debt fee

  • Shard:int - shard number of SCDO node where the debt is in

  • TxHash:string - txhash in debt

  • Hash:string - debt hash

  • debtIndex:json - debt index json

  • BlockHash:string -block hash of the block that includes the debt

  • Index:string - index of the debt in the block

  • status:string - debt status

Example

GetDebts

This method returns the pending debts in the debt pool

Type

Template

Console

client getdebts --address <address>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:json - a list of pending debts

GetInfo

This method returns node information.

Type

Template

Console

client getinfo --address <address>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • BlockAge:int64 - the age of the current block

  • Coinbase:string - the coinbase of the node

  • CurrentBlockHeight:uint64 - the current block height

  • HeaderHash:string - block hash of the current block

  • MinerStatus:string - miner status

  • PeerCnt:string - total peer connections and peer connections for each shard. 8 (1 2 3 2) means the node is connecting to a total number of 8 peers. Among them, 1 peer is in shard 1, 2 peers is in shard 2, 3 peers is in shard 3, 2 peers is in shard 2.

  • Shard:uint64 - shard number of the node

  • Version:string - the version of SCDO node

Example

GetLogs

This method gets the event logs by block height, the contract address, and the event name.

Type

Template

Console

client getlogs --height <block height> --contract <string> --abi <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • height:int64 - block height (default: -1)

  • contract:string - contract address

  • abi:string - the abi file of contract

  • event:string - the event name of contract

Returns

  • response:struct - response parameter struct

  • Txhash:string - transaction hash

  • LogIndex:uint - log index in receipt's logs

  • Log:string - log json

Example

When using the example below, the contract must be deployed first. The solidity code file:

As you can see, this example is testing the get function. In this situation, the height is the block height of the block containing the get transaction.

GetNonce

This method is used to obtain the nonce of the account.

Type

Template

Console

client getnonce --address <string> --account <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • account:string - account address

  • hash:string - hash value in hex

  • height:uint64 - block height or current block height for negative value (default: -1)

Returns

  • result:uint64 - nonce

Example

GetReceipt

This method is used to obtain the receipt contents based on transaction hash.

Type

Template

Console

client getreceipt --hash <string> --abi <string> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - hash value in hex

  • abi:string - the abi file of contract

Returns

  • contract:string - contract address

  • failed:bool - transaction executes successfully or not

  • poststate:string - state trie root hash after transaction execution

  • result:string - transaction result

  • totalFee:int - transaction fee

  • txhash:string - transaction hash

  • usedGas:int - transaction gas

Example

GetShardNum

This method is used to get the shard number of the specified account.

Type

Template

Console

client getshardnum --account <string>

Parameters

  • account:string - account address

Returns

  • shard number:uint64 - shard number

Example

GetTxInBlock

This method is used to obtain the transaction content based on block height/hash and transaction index.

Type

Template

Console

client gettxinblock --height -1 --index 0 --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • hash:string - block hash

  • height:int - block height (default: -1)

  • index:int - transaction index, start with 0 (default: 0)

Returns

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • to:string - transaction receiver

  • hash:string - transaction hash

  • payload:array - transaction payload

  • timestamp:string - transaction timestamp

Example

GetTxByHash

This method returns tx information by hash.

Type

Template

Console

client gettxbyhash --hash <string> --address <string>

Parameters

  • hash:string - hash value in hex

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • blockHash:string - block hash

  • blockHeight:int - block height

  • status:string - transaction status

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • to:string - transaction receiver

  • hash:string - transaction hash

  • payload:array - transaction payload

  • timestamp:int64 - transaction timestamp

  • txIndex:int - transaction index in block

Example

GetTxPoolContent

This method is used to obtain the transaction pool content.

Type

Template

Console

client gettxpoolcontent --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:struct - transaction pool content

Example

GetTxPoolCount

This method is used to obtain the number of transactions in the transaction pool.

Type

Template

Console

client gettxpoolcount --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:uint64 - number of transactions in the transaction pool

Example

GetPendingTxs

This method is used to obtain pending transactions in the transaction pool.

Type

Template

Console

client getpendingtxs --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:array - information of pending transactions

Example

gettxfromaccount

gettxtoaccount

Key

This method is used to generate an address/private key pair and print them out.

Type

Template

Console

client key --shard <int>

Parameters

  • shard:uint64 shard number (default: 1)

Returns

  • Account:string - account address

  • Private key:string - private key

Example

Miner

A collection of commands for miners

Miner Start

This method starts the miner.

Type

Template

Console

client miner start --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

true or false

Example

Miner Stop

This method stops the miner.

Type

Template

Console

client miner stop --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

true or false

Example

Miner Status

This method returns the miner's status.

Type

Template

Console

client miner status --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

"Running" or "Stopped"

Example

Miner GetCoinbase

This method is used to obtain the coinbase of miner consensus.

Type

Template

Console

client miner getcoinbase --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:string - coinbase

Example

Miner SetThreads

This method is used to set the threads of miner.

Type

Template

Console

client miner setthreads --threads <int> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • threads:int - miner threads (default: 0)

Returns

true or false

Example

Miner SetCoinbase

This method is used to set the coinbase

Type

Template

Console

client miner setcoinbase --coinbase <string> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • coinbase:string coinbase of the miner

Returns

true or false

Example

Miner Detrate

This method returns detrate information of the miner

Type

Template

Console

client miner detrate --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:uint64 - number of determinants computed per second by the miner

Example

Miner Threads

This method returns threads number of miner

Type

Template

Console

client miner threads --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • threads:uint64

Example

Miner GetWork

Miner GetWorkHeader

Miner SubmitWork

P2P

p2p commands

Type

Template

Console

client p2p command [command options] [arguments] --address <string>

P2P PeersInfo

This method returns the information of peer nodes.

Type

Template

Console

client p2p peersinfo --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result: the information of peers

Example

P2P Peers

This method returns the number of peer nodes.

Type

Template

Console

client p2p peers --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:int - The number of peer nodes

Example

P2P ProtocolVersion

This method returns the protocol version.

Type

Template

Console

client p2p protocolversion --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

Returns

  • result:uint64 - version number

Example

P2P AddTrustNode

P2P GetAddNodeCount

P2P GetBlockListCount

P2P IsListening

P2P NetVersion

P2P NetworkId

Payload

This method generates payload which is used to call a contract's methods.

Type

Template

Console

client payload --abi <string> --method <string> --args <string>

Parameters

  • abi:string the abi file of the contract

  • method:string the method name in the contract

  • args:string the parameters of the contract method

Returns

  • payload:string payload data

Example

SaveKey

This method saves the private key.

Type

Template

Console

`client savekey --privatekey --file --shard

Parameters

  • privatekey:string - private key of the account

  • file:string - keystore file name

  • shard:uint64 - shard number of the account (default: 1)

Returns

  • none

Example

SendTx

This method submits a transaction to the node.

Type

Template

Console

client sendtx --shard <uint64> --from <string> --to <string> --amount <uint64> --price <uint64> --gas <uint64> --nonce <uint64> --payload <string> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • shard:uint64 shard number of the sender

  • from:string - the keystore file of the sender's account

  • to:string - the receiver's address

  • amount:uint64 - the amount to transfer

  • price:uint64 - the gas price in Wen (default: "10")

  • gas:uint64 - maximum gas for transaction (default: 200000)

  • nonce:int - transaction nonce (if not given by the user, it will be retrieved from the blockchain database)

  • payload:string - transaction payload, optional

Returns

  • Hash:string - transaction hash

  • Data: transaction data

Example

Sign

This method is used to sign data with your private key.

Type

Template

Console

client sign --shard <uint64> --privatekey <string> --to <string> --amount <uint64> --price <uint64> --gas <uint64> --nonce <uint64> --payload <string> --address <string>

Parameters

  • address:string - node address for client to request (default: "127.0.0.1:8027"); you can use -a instead of --address

  • shard:uint64 shard number of the sender

  • privatekey:string private key of the sender

  • to:string account address of the receiver

  • amount:uint64 the amount to transfer

  • price:uint64 transaction gas price in Wen (default: "10")

  • gas:int64 maximum gas for transaction (default: 200000)

  • nonce:int - transaction nonce (if not given by the user, it will be retrieved from the blockchain database)

  • payload:string transaction payload, optional

Returns

  • result: transaction data with signature

Example

Last updated

Was this helpful?