CLI Commands
T-Bears provides over 20 commands, and those commands are grouped into five categories:
- T-Bears Service Commands
- T-Bears Utility Commands
- T-Bears SCORE Commands
- Other ICON JSON-RPC API Commands
- T-Bears Interactive Mode
This page contains information about the T-Bears CLI commands and their arguments.
Usage
usage: tbears [-h] [-v] command ...
tbears v1.2.1 arguments
optional arguments:
-h, --help show this help message and exit
-v, --verbose Verbose mode
Available commands:
If you want to see help message of commands, use "tbears command -h"
command
start Start tbears service
stop Stop tbears service
deploy Deploy the SCORE
clear Clear all SCOREs deployed on tbears service
test Run the unittest in the SCORE
init Initialize tbears project
samples This command has been deprecated since v1.1.0
genconf Generate tbears config files. (tbears_server_config.json,
tbears_cli_config.json and keystore_test1)
console Get into tbears interactive mode by embedding IPython
txresult Get transaction result by transaction hash
transfer Transfer ICX coin.
keystore Create a keystore file in the specified path
balance Get balance of given address in loop unit
totalsupply Query total supply of ICX in loop unit
scoreapi Get SCORE's API using given SCORE address
txbyhash Get transaction by transaction hash
lastblock Get last block's info
blockbyhash Get block info using given block hash
blockbyheight
Get block info using given block height
sendtx Request icx_sendTransaction with the specified json file and
keystore file. If keystore file is not given, tbears sends a
request as it is in the json file.
call Request icx_call with the specified json file.
Options
shorthand, Name | default | Description |
-h, --help | | Show this help message and exit |
-v, --verbose | | Verbose mode. Print debugging messages about its progress. |
Commands that manage the T-Bears server. There are three commands
tbears start
, tbears stop
and tbears clear
.Description
Start T-Bears service. Whenever T-Bears service starts, it loads the configuration from
tbears_server_config.json
file. If you want to use other configuration files, you can specify the file location with the -c
option.Usage
usage: tbears start [-h] [-a HOSTADDRESS] [-p PORT] [-c CONFIG]
Start tbears service
optional arguments:
-h, --help show this help message and exit
-a HOSTADDRESS, --address HOSTADDRESS
Address to host on (default: 127.0.0.1)
-p PORT, --port PORT Port to listen on (default: 9000)
-c CONFIG, --config CONFIG
tbears configuration file path (default:
./tbears_server_config.json)
Options
shorthand, Name | default | Description |
-h, --help | | show this help message and exit |
-a, --address | 127.0.0.1 | IP address that the T-Bears service will host on. |
-p, --port | 9000 | Port number that the T-Bears service will listen on. |
-c, --config | ./tbears_server_config.json | T-Bears configuration file path |
Description
Stop all running SCOREs and T-Bears service.
Usage
usage: tbears stop [-h]
Stop all running SCOREs and tbears service
optional arguments:
-h, --help show this help message and exit
Options
shorthand, Name | default | Description |
-h, --help | | show this help message and exit |
Description
Clear all SCOREs deployed on local T-Bears service.
Usage
usage: tbears clear [-h]
Clear all SCOREs deployed on local tbears service
optional arguments:
-h, --help show this help message and exit
Options
shorthand, Name | default | Description |
-h, --help | | show this help message and exit |
Commands that generate configuration files and a keystore file.
Description
Create a keystore file in the given path. Generate a private and public key pair using secp256k1 library.
Usage
usage: tbears keystore [-h] [-p PASSWORD] path
Create keystore file in the specified path. Generate privatekey, publickey
pair using secp256k1 library.
positional arguments:
path Path of keystore file.
optional arguments:
-h, --help show this help message and exit
-p PASSWORD, --password PASSWORD
Keystore file's password
Options
shorthand, Name | default | Description |
path | | a keystore file path that is to be generated |
-h, --help | | show this help message and exit |
-p, --password | | Password of keystore file |
Examples
(work) $ tbears keystore keystore_file
Input your keystore password:
Retype your keystore password:
Made keystore file successfully
Description
Generate T-Bears configuration files.
usage: tbears genconf [-h]
Generate T-Bears config files. (tbears_server_config.json,
tbears_cli_config.json, keystore_test1)
optional arguments:
-h, --help show this help message and exit
Options
shorthand, Name | default | Description |
-h, --help | | show this help message and exit |
Examples
(work) $ tbears genconf
Made tbears_cli_config.json, tbears_server_config.json, keystore_test1 successfully
These commands are related to SCORE development and execution.
tbears init
generates SCORE projects. tbears deploy
, tbears sendtx
and tbears call
commands are used to deploy the SCORE, send a transaction, and call a function.Description
Initialize SCORE development environment. Generate .py, package.json and test code in directory. The name of the SCORE class is . Default configuration files, "tbears_server_config.json" used when starting T-Bears and "tbears_cli_config.json" used when deploying SCORE, are also generated.
Usage
usage: tbears init [-h] project scoreClass
Initialize SCORE development environment. Generate <project>.py, package.json
and test code in <project> directory. The name of the score class is
<scoreClass>.
positional arguments:
project Project name
scoreClass SCORE class name
optional arguments:
-h, --help show this help message and exit
Options
shorthand, Name | default | Description |
project | | Project name |
scoreClass | | SCORE class name |
-h, --help | | show this help message and exit |
Examples
(work) $ tbears init hello HelloWorld
Initialized hello successfully
(work) $ ls hello
__init__.py hello.py package.json tests
File description
Item | Description |
tbears_server_config.json | T-Bears default configuration file will be created on the working directory. |
tbears_cli_config.json | Configuration file for CLI commands will be created on the working directory. |
keystore_test1 | Keystore file for test account will be created on the working directory. |
| SCORE project name. Project directory is created with the same name. |
/__init__.py | __init__.py file to make the project directory recognized as a python package. |
/package.json | Contains the information needed when SCORE is loaded.
"main_module" and "main_class" should be specified. |
/.py | SCORE main file, where scoreClass is defined. |
/tests | Directory for SCORE test code. |
/tests/__init__.py | __init__.py file to make the test directory recognized as a python package. |
/tests/test_.py | SCORE test main file. |
Description
Deploy the SCORE. You can deploy it on local T-Bears service or on ICON network.
tbears_cli_config.json
file contains the deployment configuration properties. (See below 'Configuration Files' chapter). If you want to use other configuration files, you can specify the file location with the -c
option.Usage
usage: tbears deploy [-h] [-u URI] [-t {tbears,zip}] [-m {install,update}]
[-f FROM] [-o TO] [-k KEYSTORE] [-n NID] [-p PASSWORD]
[-s STEPLIMIT] [-c CONFIG]
project
Deploy the SCORE
positional arguments:
project Project directory path or zip file path
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-t {tbears,zip}, --type {tbears,zip}
This option is deprecated since version 1.0.5. Deploy
command supports zip type only
-m {install,update}, --mode {install,update}
Deploy mode (default: install)
-f FROM, --from FROM From address. i.e. SCORE owner address
-o TO, --to TO To address. i.e. SCORE address
-k KEYSTORE, --key-store KEYSTORE
Keystore file path. Used to generate "from" address
and transaction signature
-n NID, --nid NID Network ID
-p PASSWORD, --password PASSWORD
keystore file's password
-s STEPLIMIT, --step-limit STEPLIMIT
Step limit
-c CONFIG, --config CONFIG
deploy config path (default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
project | | Project directory or zip file which contains the SCORE package. If you want to deploy with a zip file, zip the project directory |
-h, --help | | show this help message and exit |
-u, --node-uri | URI of node | |
-m {install,update},
--mode {install,update} | install | Deploy mode ("install" or "update"). |
-f, --from | | From address. i.e. SCORE owner address. It is ignored if keystore is set |
-o, --to | | To address. i.e. SCORE address
This parameter is required when updating SCORE. |
-k, --key-store | | Keystore file path for SCORE owner |
-n, --nid | | Network ID of node.
Each network has unique ID. If the Network ID does not match, node will reject the SCORE. Network ID will be announced when a network opens to public.
0x3 is reserved for T-Bears service. However, T-Bears service does not verify the Network ID. |
-p, --password | | Password of keystore file |
-s, --step-limit | an estimated Step | Step limit of the transaction |
-c, --config | ./tbears_cli_config.json | Configuration file path |
Examples
# you can deploy a SCORE to the local T-Bears server without verifying signature
(work) $ tbears deploy hello
# when you deploy a SCORE to ICON, you need to specify the keystore file
# config.json should contain valid parameters like node-uri, nid, etc.
(work) $ tbears deploy hello -k keystore -c config.json
Input your keystore password:
Send deploy request successfully.
If you want to check SCORE deployed successfully, execute txresult command
transaction hash: 0x9c294b9608d9575f735ec2e2bf52dc891d7cca6a2fa7e97aee4818325c8a9d41
# when you update the SCORE 'hello', you need to specify the SCORE address with the '-o' option
(work) $ tbears deploy hello -m update -o cx6bd390bd855f086e3e9d525b46bfe24511431532 -k keystore -c config.json
Input your keystore password:
Send deploy request successfully.
If you want to check SCORE deployed successfully, execute txresult command
transaction hash: 0xad292b9608d9575f735ec2ebbf52dc891d7cca6a2fa7e97aee4818325c80934d
T-Bears can supply some required fields on behalf of the sender when those are not specified in the configuration file. T-Bears will generate a valid JSON request using the following rules.
Field name | Description |
stepLimit | |
timestamp | The current time will be set |
Description
Run the unittest in the project.
Usage
usage: tbears test [-h] project
Run the unittest in the project
positional arguments:
project Project directory path
optional arguments:
-h, --help show this help message and exit
Options
shorthand, Name | default | Description |
project | | Project directory which contains the SCORE package and test code. |
-h, --help | | show this help message and exit |
Examples
(work) $ tbears test hello
..
----------------------------------------------------------------------
Ran 2 tests in 0.172s
OK
Description
Request
icx_sendTransaction
with the specified json file.usage: tbears sendtx [-h] [-u URI] [-k KEYSTORE] [-p PASSWORD] [-s STEPLIMIT]
[-c CONFIG]
json_file
Request icx_sendTransaction with the specified json file and keystore file. If
keystore file is not given, tbears sends a request as it is in the json file.
positional arguments:
json_file File path containing icx_sendTransaction content
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-k KEYSTORE, --key-store KEYSTORE
Keystore file path. Used to generate "from" address
and transaction signature
-p PASSWORD, --password PASSWORD
Keystore file's password
-s STEPLIMIT, --step-limit STEPLIMIT
Step limit
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
values for "keyStore", "uri", "from" and "stepLimit".
(default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
json_file | | Path to the json file containing the request object for icx_transaction. |
-h, --help | | show this help message and exit |
-u, --node-uri | URI of node | |
-k, --key-store | | Keystore file path. Used to generate transaction signature. |
-p, --password | | Password of keystore file |
-s, --step-limit | an estimated Step | Step limit of the transaction |
-c, --config | ./tbears_cli_config.json | Configuration file path. This file defines the default values for "keyStore", "uri", "from" and "stepLimit". |
Examples
(work) $ cat send.json
{
"jsonrpc": "2.0",
"method": "icx_sendTransaction",
"params": {
"version": "0x3",
"from": "hxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6",
"to": "cx4d5a79f329adcf00a3daa99539f0eeea2d43d239",
"nid": "0x3",
"dataType": "call",
"data": {
"method": "setValue",
"params": {
"value": "0x123"
}
}
}
}
(work) $ tbears sendtx send.json -k keystore
Input your keystore password:
Send transaction request successfully.
transaction hash: 0xc8a3e3f77f21f8f1177d829cbc4c0ded6fd064cc8e42ef309dacff5c0a952289
T-Bears can supply some required fields on behalf of the sender when those are not specified in the
json_file
. In the example above, stepLimit
and timestamp
fields are not specified, but T-Bears can make a valid JSON request using the following rules.Field name | Description |
stepLimit | |
timestamp | The current time will be set |
Description
Request
icx_call
with the specified json file.usage: tbears call [-h] [-u URI] [-c CONFIG] json_file
Request icx_call with the specified json file.
positional arguments:
json_file File path containing icx_call content
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
value for "uri" (default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
json_file | | Path to the json file containing the request object for icx_call |
-h, --help | | Show this help message and exit |
-u, --node-uri | URI of node | |
-c, --config | ./tbears_cli_config.json | Configuration file path. This file defines the default values for "uri". |
Examples
(work) $ cat call.json
{
"jsonrpc": "2.0",
"method": "icx_call",
"params": {
"to": "cx53d5080a7d8a805bb10eb9bc64637809dc910832",
"dataType": "call",
"data": {
"method": "hello"
}
},
"id": 1
}
(work) $ tbears call call.json
response : {
"jsonrpc": "2.0",
"result": "Hello",
"id": 1
}
Description
Get a list of APIs that the given SCORE provides. Please refer to
icx_getScoreApi
of ICON JSON-RPC API v3 for details.Usage
usage: tbears scoreapi [-h] [-u URI] [-c CONFIG] address
Get SCORE's API using given SCORE address
positional arguments:
address SCORE address to query the API
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
value for "uri" (default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
address | | SCORE address to query APIs |
-h, --help | | show this help message and exit |
-u, --node-uri | URI of node. | |
-c, --config | ./tbears_cli_config.json | Configuration file path. This file defines the default value for "uri". |
Examples
(work) $ tbears scoreapi cx0123456789abcdef0123456789abcdefabcdef12
SCORE API: [
{
"type": "function",
"name": "hello",
"inputs": [],
"outputs": [
{
"type": "str"
}
],
"readonly": "0x1"
},
{
"type": "function",
"name": "setValue",
"inputs": [
{
"name": "value",
"type": "int"
}
],
"outputs": []
}
]
Commands that are related to ICX coin, transaction, and block.
Description
Transfer designated amount of ICX coins.
Usage
usage: tbears transfer [-h] [-f FROM] [-k KEYSTORE] [-n NID] [-u URI]
[-p PASSWORD] [-s STEPLIMIT] [-c CONFIG]
to value
Transfer ICX coin.
positional arguments:
to Recipient
value Amount of ICX coin in loop to transfer (1 icx = 1e18
loop)
optional arguments:
-h, --help show this help message and exit
-f FROM, --from FROM From address.
-k KEYSTORE, --key-store KEYSTORE
Keystore file path. Used to generate "from" address
and transaction signature
-n NID, --nid NID Network ID (default: 0x3)
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-p PASSWORD, --password PASSWORD
Keystore file's password
-s STEPLIMIT, --step-limit STEPLIMIT
Step limit
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
values for "keyStore", "uri", "from" and "stepLimit".
(default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
to | | Recipient address. |
value | | Amount of ICX coin in loop to transfer to "to" address. (1 icx = 1e18 loop) |
-h, --help | | show this help message and exit |
-f, --from | | From address. It is ignored if keystore is set |
-k, --key-store | | Keystore file path. Used to generate "from" address and transaction signature. |
-u, --node-uri | URI of node | |
-n, --nid | 0x3 | Network ID |
-p, --password | | Password of keystore file |
-s, --step-limit | an estimated Step | Step limit of the transaction |
-c, --config | ./tbears_cli_config.json | Configuration file path. This file defines the default values for "keyStore", "uri", "from" and "stepLimit". |
Examples
(work) $ tbears transfer -k test_keystore hxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab 1e18
Send transfer request successfully.
transaction hash: 0xc1b92b9a08d8575f735ec2ebbf52dc831d7c2a6a2fa7e97aee4818325cad919e
Description
Get balance of given address.
Usage
usage: tbears balance [-h] [-u URI] [-c CONFIG] address
Get balance of given address in loop unit
positional arguments:
address Address to query the ICX balance
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
value for "uri" (default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
address | | Address to query the ICX balance |
-h, --help | | show this help message and exit |
-u, --node-uri | URI of node | |
-c, --config | ./tbears_cli_config.json | Configuration file path. This file defines the default value for "uri". |
Examples
(work) $ tbears balance hx0123456789abcdef0123456789abcdefabcdef12
balance in hex: 0x2961fff8ca4a62327800000
balance in decimal: 800460000000000000000000000
Description
Query total supply of ICX.
Usage
usage: tbears totalsupply [-h] [-u URI] [-c CONFIG]
Query total supply of ICX in loop unit
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
value for "uri" (default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
-h, --help | | show this help message and exit |
-u, --node-uri | URI of node | |
-c, --config | ./tbears_cli_config.json | Configuration file path. This file defines the default value for "uri". |
Examples
(work) $ tbears totalsupply
Total supply of ICX in hex: 0x2961fff8ca4a62327800000
Total supply of ICX in decimal: 800460000000000000000000000
Description
Get transaction result by transaction hash.
Usage
usage: tbears txresult [-h] [-u URI] [-c CONFIG] hash
Get transaction result by transaction hash
positional arguments:
hash Transaction hash of the transaction to be queried.
optional arguments:
-h, --help show this help message and exit
-u URI, --node-uri URI
URI of node (default: http://127.0.0.1:9000/api/v3)
-c CONFIG, --config CONFIG
Configuration file path. This file defines the default
value for "uri" (default: ./tbears_cli_config.json)
Options
shorthand, Name | default | Description |
hash | | Hash of the transaction to be queried |