Package: tbears
ICON SCORE Development Suite (T-Bears) TutorialThis tutorial is intended to give an introduction to using T-Bears. This guide will walk you through the basics of setting up your development environment and the usage of T-Bears CLI commands.T-Bears is a suite of development tools for SCORE. T-Bears provides a project template for SCORE to help you start right away. You can code and test your smart contract locally in an emulated environment, and when ready, deploy SCORE onto the ICON network from command-line interface.ComponentsICON RPC ServerA module that handles ICON JSON-RPC API request and sends response back to the client.ICON ServiceA module that manages the lifecycle of SCORE and its execution. SCORE's state transition is stored in a database.T-Bears CLIT-Bears Command Line Interface. Supports following functions:Manage T-Bears serviceDeploy SCORESend transactionSend query requestFor the details, see below 'Command-line Interfaces (CLIs)' chapter.T-Bears Block ManagerLoopchain emulator for T-Bears Service. It does not have full 'consensus' and 'peer management' functions. This module handles transaction and emulates block generation.Message queueMessage queue is used for inter-component communication.Quick startYou can run T-Bears on your machine by using Docker.The below command will download T-Bears Docker image and run T-Bears Docker container.dockerrun-it-p9000:9000iconloop/tbears:mainnetPlease check the following links for more information.T-Bears DockerBuilding from sourceFirst, clone this project. Then go to the project directory, create a virtualenv environment, and run build script. You can then install T-Bears with the .whl file.$virtualenv-ppython3venv# Create a virtual environment.$sourcevenv/bin/activate# Enter the virtual environment.(venv)$./build.sh# run build script(venv)$lsdist/# check result wheel filetbears-x.y.z-py3-none-any.whlInstallationThis chapter will explain how to install T-Bears on your system.RequirementsICON SCORE development and execution requires following environments :OS: MacOS or LinuxWindows is not supported.PythonMake a virtualenv for Python 3.6.5+ (3.7 is also supported)Check your Python version$python3-VIDE: Pycharm is recommended.SoftwaresRabbitMQ: 3.7 and above.homepageLibrariesnamedescriptiongithubLevelDBICON SCORE uses levelDB to store its states.LevelDB GitHubSetup on MacOS# install develop tools$brewinstallleveldb
$brewinstallautoconfautomakelibtoolpkg-config# install RabbitMQ and start service$brewinstallrabbitmq
$brewservicesstartrabbitmq# Create a working directory$mkdirwork
$cdwork# setup the python virtualenv development environment$pip3installvirtualenv
$virtualenv-ppython3.
$sourcebin/activate# Install the ICON SCORE dev tools(work)$pipinstalltbearsSetup on Linux# Install levelDB$sudoapt-getinstalllibleveldb-dev# install RabbitMQ and start service$sudoapt-getinstallrabbitmq-server
$sudoservicerabbitmq-serverstart# Create a working directory$mkdirwork
$cdwork# Setup the python virtualenv development environment$virtualenv-ppython3.
$sourcebin/activate# Install the ICON SCORE dev tools(work)$pipinstalltbearsHow to use T-BearsCommand-line Interfaces (CLIs)OverviewT-Bears provides over 20 commands. Here is the available commands list.Usageusage:tbears[-h][-v]command...

tbearsv1.2.1arguments

optionalarguments:-h,--helpshowthishelpmessageandexit-v,--verboseVerbosemode

Availablecommands:Ifyouwanttoseehelpmessageofcommands,use"tbears command -h"commandstartStarttbearsservicestopStoptbearsservicesync_mainnetSynchronizerevisionandgovernanceSCOREwiththemainnetdeployDeploytheSCOREclearClearallSCOREsdeployedontbearsservicetestRuntheunittestintheSCOREinitInitializetbearsprojectsamplesThiscommandhasbeendeprecatedsincev1.1.0genconfGeneratetbearsconfigfiles.(tbears_server_config.json,tbears_cli_config.jsonandkeystore_test1)consoleGetintotbearsinteractivemodebyembeddingIPythontxresultGettransactionresultbytransactionhashtransferTransferICXcoin.keystoreCreateakeystorefileinthespecifiedpathkeyinfoShowakeystorefileinformationthespecifiedpathbalanceGetbalanceofgivenaddressinloopunittotalsupplyQuerytotalsupplyofICXinloopunitscoreapiGetscore's api using given score addresstxbyhash     Get transaction by transaction hashlastblock    Get last block'sinfoblockbyhashGetblockinfousinggivenblockhashblockbyheightGetblockinfousinggivenblockheightsendtxRequesticx_sendTransactionwiththespecifiedjsonfileandkeystorefile.Ifkeystorefileisnotgiven,tbearssendsrequestasitisinthejsonfile.callRequesticx_callwiththespecifiedjsonfile.Optionsshorthand, NamedefaultDescription-h, --helpShow this help message and exit-v, --verboseVerbose mode. Print debugging messages about its progress.T-Bears server commandsCommands that manage the T-Bears server. There are three commandstbears start,tbears stop,tbears clearandtbears sync_mainnet.tbears startDescriptionStart T-Bears service. Whenever T-Bears service starts, it loads the configuration fromtbears_server_config.jsonfile. If you want to use other configuration file, you can specify the file location with the-coption.Usageusage:tbearsstart[-h][-aHOSTADDRESS][-pPORT][-cCONFIG]Starttbearsservice

optionalarguments:-h,--helpshowthishelpmessageandexit-aHOSTADDRESS,--addressHOSTADDRESSAddresstohoston(default:127.0.0.1)-pPORT,--portPORTPorttolistenon(default:9000)-cCONFIG,--configCONFIGtbearsconfigurationfilepath(default:./tbears_server_config.json)Optionsshorthand, NamedefaultDescription-h, --helpshow this help message and exit-a, --address127.0.0.1IP address that the T-Bears service will host on.-p, --port9000Port number that the T-Bears service will listen on.-c, --config./tbears_server_config.jsonT-Bears configuration file pathtbears stopDescriptionStop all running SCOREs and T-Bears service.Usageusage:tbearsstop[-h]StopallrunningSCOREsandtbearsservice

optionalarguments:-h,--helpshowthishelpmessageandexitOptionsshorthand, NamedefaultDescription-h, --helpshow this help message and exittbears clearDescriptionClear all SCOREs deployed on local T-Bears service.Usageusage:tbearsclear[-h]ClearallSCOREsdeployedonlocaltbearsservice

optionalarguments:-h,--helpshowthishelpmessageandexitOptionsshorthand, NamedefaultDescription-h, --helpshow this help message and exittbears sync_mainnetDescriptionSynchronize revision and governance SCORE with the mainnetUsageusage:tbearssync_mainnet[-h]SynchronizerevisionandgovernanceSCOREwiththemainnet

optionalarguments:-h,--helpshowthishelpmessageandexitOptionsshorthand, NamedefaultDescription-h, --helpshow this help message and exitT-Bears utility commandsCommands that generate configuration file and keystore file.tbears keystoreDescriptionCreate a keystore file in the given path. Generate a private and public key pairUsageusage:tbearskeystore[-h][-pPASSWORD]path

Createkeystorefileinthespecifiedpath.Generateprivatekey,publickey
pair

positionalarguments:pathPathofkeystorefile.

optionalarguments:-h,--helpshowthishelpmessageandexit-pPASSWORD,--passwordPASSWORDKeystorefile'spasswordOptionsshorthand, NamedefaultDescriptionpatha keystore file path that is to be generated-h, --helpshow this help message and exit-p, --passwordKeystore file's passwordExamples(work)$tbearskeystorekeystore_file
Inputyourkeystorepassword:
Retypeyourkeystorepassword:
Madekeystorefilesuccessfullytbears keyinfoDescriptionShow a keystore information(address, privateKey, publicKey) in the specified path.Usageusage:tbearskeyinfo[-h][-pPASSWORD][--private-key]path

Showakeystoreinformation(address,privateKey,publicKey)inthespecified
path.IfyouwanttogetprivateKey,input--private-keyoption

positionalarguments:pathPathofkeystorefile.

optionalarguments:-h,--helpshowthishelpmessageandexit-pPASSWORD,--passwordPASSWORDKeystorefile'spassword--private-keyoptionthatwhethershowprivateKeyOptionsshorthand, NamedefaultDescriptionpatha keystore file path that is to be shown-h, --helpshow this help message and exit-p, --passwordKeystore file's password--private-keyoption that whether show privateKeyExamples(work)$tbearskeyinfokeystore
Inputyourkeystorepassword:{"address":"hxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6","publicKey":"0x040d60ccc4fd29307304a8e84715e6e1a2e643bcff14fbf90d9099dfc84585a6f6f0b6944594efebe433a12a005ba56d215d6e51697a3360b5d741f8db89955c66"}(work)$tbearskeyinfo--private-keykeystore
Inputyourkeystorepassword:{"address":"hxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6","publicKey":"0x040d60ccc4fd29307304a8e84715e6e1a2e643bcff14fbf90d9099dfc84585a6f6f0b6944594efebe433a12a005ba56d215d6e51697a3360b5d741f8db89955c66","privateKey":"54483cf6c525f831da699d73d273e48aa88c963ed5ac485b207c7bf4a57ddce1"}tbears genconfDescriptionGenerate T-Bears config files and keystore files.usage:tbearsgenconf[-h]GenerateT-Bearsconfigfilesandkeystorefiles.

optionalarguments:-h,--helpshowthishelpmessageandexitOptionsshorthand, NamedefaultDescription-h, --helpshow this help message and exitExamples(work)$tbearsgenconf
Madetbears_cli_config.json,tbears_server_config.json,./keystore/*successfullyT-Bears SCORE commandsThese commands are related to SCORE development and execution.tbears initgenerates SCORE projects.tbears deploy,tbears sendtxandtbears callcommands are used to deploy the SCORE, send a transaction, and call a function.tbears initDescriptionInitialize SCORE development environment. Generate <project>.py, package.json and test code in <project> directory. The name of the SCORE class is <scoreClass>.  Default configuration files, "tbears_server_config.json" used when starting T-Bears and "tbears_cli_config.json" used when deploying SCORE, are also generated.Usageusage:tbearsinit[-h]projectscoreClass

InitializeSCOREdevelopmentenvironment.Generate<project>.py,package.json
andtestcodein<project>directory.Thenameofthescoreclassis
<scoreClass>.

positionalarguments:projectProjectnamescoreClassSCOREclassname

optionalarguments:-h,--helpshowthishelpmessageandexitOptionsshorthand, NamedefaultDescriptionprojectProject namescoreClassSCORE class name-h, --helpshow this help message and exitExamples(work)$tbearsinithelloHelloWorld
Initializedhellosuccessfully(work)$lshello
__init__.pyhello.pypackage.jsontestsFile descriptionItemDescriptiontbears_server_config.jsonT-Bears default configuration file will be created on the working directory.tbears_cli_config.jsonConfiguration file for CLI commands will be created on the working directory.keystore/*Keystore file for test account and P-Reps.<project>SCORE project name. Project directory is created with the same name.<project>/__init__.py__init__.py file to make the project directory recognized as a python package.<project>/package.jsonContains the information needed when SCORE is loaded."main_module" and "main_class" should be specified.<project>/.pySCORE main file, wherescoreClassis defined.<project>/testsDirectory for SCORE test code.<project>/tests/__init__.py__init__.py file to make the test directory recognized as a python package.<project>/tests/test_.pySCORE test main file.tbears deployDescriptionDeploy 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 file, you can specify the file location with the '-c' option.Usageusage:tbearsdeploy[-h][-uURI][-t{tbears,zip}][-m{install,update}][-fFROM][-oTO][-kKEYSTORE][-nNID][-pPASSWORD][-sSTEPLIMIT][-cCONFIG]project

DeploytheSCORE

positionalarguments:projectProjectdirectorypathorzipfilepath

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-t{tbears,zip},--type{tbears,zip}Thisoptionisdeprecatedsinceversion1.0.5.Deploycommandsupportsziptypeonly-m{install,update},--mode{install,update}Deploymode(default:install)-fFROM,--fromFROMFromaddress.i.e.SCOREowneraddress-oTO,--toTOToaddress.i.e.SCOREaddress-kKEYSTORE,--key-storeKEYSTOREKeystorefilepath.Usedtogenerate"from"addressandtransactionsignature-nNID,--nidNIDNetworkID-pPASSWORD,--passwordPASSWORDkeystorefile'spassword-sSTEPLIMIT,--step-limitSTEPLIMITSteplimit-cCONFIG,--configCONFIGdeployconfigpath(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionprojectProject directory or zip file which contains the SCORE package. If you want to deploy with a zip file, zip the project directory-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-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}installDeploy mode ("install" or "update").-f, --fromFrom address. i.e. SCORE owner address. It is ignored if keystore is set-o, --toTo address. i.e. SCORE addressThis parameter is required when updating SCORE.-k, --key-storeKeystore file path for SCORE owner-n, --nidNetwork 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, --passwordPassword of keystore file-s, --step-limitan estimated StepStep limit of the transaction-c, --config./tbears_cli_config.jsonConfiguration file pathExamples# you can deploy a SCORE to the local T-Bears server without verifying signature(work)$tbearsdeployhello# 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)$tbearsdeployhello-kkeystore-cconfig.json
Inputyourkeystorepassword:
Senddeployrequestsuccessfully.
IfyouwanttocheckSCOREdeployedsuccessfully,executetxresultcommandtransactionhash:0x9c294b9608d9575f735ec2e2bf52dc891d7cca6a2fa7e97aee4818325c8a9d41# when you update the SCORE 'hello', you need to specify the SCORE address with the '-o' option(work)$tbearsdeployhello-mupdate-ocx6bd390bd855f086e3e9d525b46bfe24511431532-kkeystore-cconfig.json
Inputyourkeystorepassword:
Senddeployrequestsuccessfully.
IfyouwanttocheckSCOREdeployedsuccessfully,executetxresultcommandtransactionhash:0xad292b9608d9575f735ec2ebbf52dc891d7cca6a2fa7e97aee4818325c80934dT-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 nameDescriptionstepLimitThe estimated Step usage (debug_estimateStepAPI is used) will be set for the transactiontimestampThe current time will be settbears testDescriptionRun the unittest in the project.Usageusage:tbearstest[-h]project

Runtheunittestintheproject

positionalarguments:projectProjectdirectorypath

optionalarguments:-h,--helpshowthishelpmessageandexitOptionsshorthand, NamedefaultDescriptionprojectProject directory which contains the SCORE package and test code.-h, --helpshow this help message and exitExamples(work)$tbearstesthello
..
----------------------------------------------------------------------
Ran2testsin0.172s

OKtbears sendtxDescriptionRequesticx_sendTransactionwith the specified json file.usage:tbearssendtx[-h][-uURI][-kKEYSTORE][-cCONFIG][-pPASSWORD][-sSTEPLIMIT]json_file

Request`icx_sendTransaction`withthespecifiedjsonfileandkeystorefile.If
keystorefileisnotgiven,tbearssendsrequestasitisinthejsonfile.

positionalarguments:json_fileFilepathcontainingicx_sendTransactioncontent

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-kKEYSTORE,--key-storeKEYSTOREKeystorefilepath.Usedtogenerate"from"addressandtransactionsignature-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)-pPASSWORD,--passwordPASSWORDKeystorefile'spassword-sSTEPLIMIT,--step-limitSTEPLIMITSteplimitOptionsshorthand, NamedefaultDescriptionjson_filePath to the json file containing the request object for icx_transaction.-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-k, --key-storeKeystore file path. Used to generate transaction signature.-p, --passwordPassword of keystore file-s, --step-limitan estimated StepStep limit of the transaction-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default values for the properties "keyStore", "uri" and "from".Examples(work)$catsend.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)$tbearssendtxsend.json-kkeystore
Inputyourkeystorepassword:
Sendtransactionrequestsuccessfully.
transactionhash:0xc8a3e3f77f21f8f1177d829cbc4c0ded6fd064cc8e42ef309dacff5c0a952289T-Bears can supply some required fields on behalf of the sender when those are not specified in thejson_file.
In the example above,stepLimitandtimestampfields are not specified, but T-Bears can make a valid JSON request using the following rules.Field nameDescriptionstepLimitThe estimated Step usage (debug_estimateStepAPI is used) will be set for the transactiontimestampThe current time will be settbears callDescriptionRequesticx_callwith the specified json file.usage:tbearscall[-h][-uURI][-cCONFIG]json_file

Requesticx_callwiththespecifiedjsonfile.

positionalarguments:json_fileFilepathcontainingicx_callcontent

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionjson_filePath to the json file containing the request object for icx_call-h, --helpShow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default values for the properties "keyStore", "uri" and "from".Examples(work)$catcall.json{"jsonrpc":"2.0","method":"icx_call","params":{"to":"cx53d5080a7d8a805bb10eb9bc64637809dc910832","dataType":"call","data":{"method":"hello"}},"id":1}(work)$tbearscallcall.json
response:{"jsonrpc":"2.0","result":"Hello","id":1}tbears scoreapiDescriptionGet list of APIs that the given SCORE provides. Please refer toicx_getScoreApiofICON JSON-RPC API v3for details.Usageusage:tbearsscoreapi[-h][-uURI][-cCONFIG]address

GetSCORE'sAPIusinggivenSCOREaddress

positionalarguments:addressSCOREaddresstoquerySCOREAPI

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionaddressSCORE address to query APIs-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node.-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearsscoreapicx0123456789abcdef0123456789abcdefabcdef12
SCOREAPI:[{"type":"function","name":"hello","inputs":[],"outputs":[{"type":"str"}],"readonly":"0x1"},{"type":"function","name":"setValue","inputs":[{"name":"value","type":"int"}],"outputs":[]}]T-Bears other commandsCommands that are related to ICX coin, transaction, and block.tbears transferDescriptionTransfer designated amount of ICX coins.Usageusage:tbearstransfer[-h][-fFROM][-kKEYSTORE][-nNID][-uURI][-pPASSWORD][-sSTEPLIMIT][-cCONFIG]tovalue

TransferICXcoin.

positionalarguments:toRecipientvalueAmountofICXcoininlooptotransfer(1icx=1e18loop)optionalarguments:-h,--helpshowthishelpmessageandexit-fFROM,--fromFROMFromaddress.-kKEYSTORE,--key-storeKEYSTOREKeystorefilepath.Usedtogenerate"from"addressandtransactionsignature-nNID,--nidNIDNetworkID(default:0x3)-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-pPASSWORD,--passwordPASSWORDKeystorefile'spassword-sSTEPLIMIT,--step-limitSTEPLIMITSteplimit-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvaluesfortheproperties"keyStore","uri","from"and"stepLimit".(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptiontoRecipient address.valueAmount of ICX coin in loop to transfer to "to" address. (1 icx = 1e18 loop)-h, --helpshow this help message and exit-f, --fromFrom address. It is ignored if keystore is set-k, --key-storeKeystore file path. Used to generate "from" address and transaction signature.-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-n, --nid0x3Network ID-p, --passwordPassword of keystore file-s, --step-limitan estimated StepStep limit of the transaction-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default values for the properties "keyStore", "uri" and "from".Examples(work)$tbearstransfer-ktest_keystorehxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab1e18
Sendtransferrequestsuccessfully.
transactionhash:0xc1b92b9a08d8575f735ec2ebbf52dc831d7c2a6a2fa7e97aee4818325cad919etbears balanceDescriptionGet balance of given address.Usageusage:tbearsbalance[-h][-uURI][-cCONFIG]address

Getbalanceofgivenaddressinloopunit

positionalarguments:addressAddresstoquerytheICXbalance

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionaddressAddress to query the ICX balance-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearsbalancehx0123456789abcdef0123456789abcdefabcdef12
balanceinhex:0x2961fff8ca4a62327800000
balanceindecimal:800460000000000000000000000tbears totalsupplyDescriptionQuery total supply of ICX.Usageusage:tbearstotalsupply[-h][-uURI][-cCONFIG]QuerytotalsupplyofICXinloopunit

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescription-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearstotalsupply
TotalsupplyofICXinhex:0x2961fff8ca4a62327800000
TotalsupplyofICXindecimal:800460000000000000000000000tbears txresultDescriptionGet transaction result by transaction hash.Usageusage:tbearstxresult[-h][-uURI][-cCONFIG]hashGettransactionresultbytransactionhashpositionalarguments:hashTransactionhashofthetransactiontobequeried.

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionhashHash of the transaction to be queried-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearstxresult0x227fb3e6fdc89de8d24e019b1ddc88538633c4202102297da204444d393249c2
Transactionresult:{"jsonrpc":"2.0","result":{"txHash":"0x227fb3e6fdc89de8d24e019b1ddc88538633c4202102297da204444d393249c2","blockHeight":"0x2","blockHash":"28e6e4710c56e053920b95df0058317a4ac641b16d17d64db7f958e8a5650391","txIndex":"0x0","to":"cx0000000000000000000000000000000000000000","scoreAddress":"cx6bd390bd855f086e3e9d525b46bfe24511431532","stepUsed":"0xe2a4","stepPrice":"0x0","cumulativeStepUsed":"0xe2a4","eventLogs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","status":"0x1"},"id":1}tbears txbyhashDescriptionGet transaction by transaction hashUsageusage:tbearstxbyhash[-h][-uURI][-cCONFIG]hashGettransactionbytransactionhashpositionalarguments:hashHashofthetransactiontobequeried

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionhashHash of the transaction to be queried-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearstxbyhash0x95be9f0247bc3b7ed07fe07c53613c580642ef991c574c85db45dbac9e8366df

Transaction:{"jsonrpc":"2.0","result":{"version":"0x3","from":"hxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","value":"0x0","stepLimit":"0x3000000","timestamp":"0x572e8fd95db26","nid":"0x3","nonce":"0x1","to":"cx0000000000000000000000000000000000000000","data":{"contentType":"application/zip","content":"0x32b34cfa39993fa093e","params":{}},"dataType":"deploy","signature":"sig","txIndex":"0x0","blockHeight":"0x2","blockHash":"0x28e6e4710c56e053920b95df0058317a4ac641b16d17d64db7f958e8a5650391"},"id":1}tbears lastblockDescriptionQuery last block info. When running on T-Bears service, "merkle_tree_root_hash" and "signature" will be empty.Usageusage:tbearslastblock[-h][-uURI][-cCONFIG]Getlastblockinfo

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescription-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearslastblock

blockinfo:{"jsonrpc":"2.0","result":{"version":"tbears","prev_block_hash":"815c0fd7a0dd4594bb19ee39030c1bd91c200878f1f456fe8dd7ff4e0a19b839","merkle_tree_root_hash":"tbears_does_not_support_merkel_tree","time_stamp":1533719896011654,"confirmed_transaction_list":[{"version":"0x3","from":"hxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","value":"0x0","stepLimit":"0x3000000","timestamp":"0x572e8fd95db26","nid":"0x3","nonce":"0x1","to":"cx0000000000000000000000000000000000000000","data":{"contentType":"application/zip","content":"0x32b34cfa39993fa093e","params":{}},"dataType":"deploy","signature":"sig"}],"block_hash":"28e6e4710c56e053920b95df0058317a4ac641b16d17d64db7f958e8a5650391","height":2,"peer_id":"fb5f43dc-9aeb-11e8-a31b-acde48001122","signature":"tbears_does_not_support_signature"},"id":1}tbears blockbyheightDescriptionGet block info using given block height.Usageusage:tbearsblockbyheight[-h][-uURI][-cCONFIG]height

Getblockinfousinggivenblockheight

positionalarguments:heightheightoftheblocktobequeried

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Optionsshorthand, NamedefaultDescriptionheightHeight of the block to be queried-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Examples(work)$tbearsblockbyheight0x1

blockinfo:{"jsonrpc":"2.0","result":{"version":"tbears","prev_block_hash":"859083707985809a8b52982b9d8d86bfe48c0020a478b3a99d7eeb3c74c38e7c","merkle_tree_root_hash":"tbears_does_not_support_merkel_tree","time_stamp":1533719753948440,"confirmed_transaction_list":[{"version":"0x3","from":"hxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6","value":"0x8ac7230489e80000","stepLimit":"0x2000","timestamp":"0x572e8f51e4481","nid":"0x3","nonce":"0x1","to":"hxbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab","signature":"f2B3r27u7peL3I9uBnKA8yn82odqlMECU+UBkRiZTJIwWFo57AmlUjKhoK8OZBBRdaWWmLF+JTZNs70yF8+zIwA="}],"block_hash":"815c0fd7a0dd4594bb19ee39030c1bd91c200878f1f456fe8dd7ff4e0a19b839","height":1,"peer_id":"a6b22354-9aeb-11e8-a0ae-acde48001122","signature":"tbears_does_not_support_signature"},"id":1}tbears blockbyhashDescriptionGet block info using given block hash.Optionsshorthand, NamedefaultDescriptionhashHash of the block to be queried-h, --helpshow this help message and exit-u, --node-urihttp://127.0.0.1:9000/api/v3URI of node-c, --config./tbears_cli_config.jsonConfiguration file path. This file defines the default value for the "uri".Usageusage:tbearsblockbyhash[-h][-uURI][-cCONFIG]hashGetblockinfousinggivenblockhashpositionalarguments:hashhashoftheblocktobequeried

optionalarguments:-h,--helpshowthishelpmessageandexit-uURI,--node-uriURIURIofnode(default:http://127.0.0.1:9000/api/v3)-cCONFIG,--configCONFIGConfigurationfilepath.Thisfiledefinesthedefaultvalueforthe"uri"(default:./tbears_cli_config.json)Examples(work)$tbearsblockbyhash0xce00facd0ac3832e1e6e623d8f4b9344782da881e55abb48d1494fde9e465f78

blockinfo:{"jsonrpc":"2.0","result":{"version":"tbears","prev_block_hash":"859083707985809a8b52982b9d8d86bfe48c0020a478b3a99d7eeb3c74c38e7c","merkle_tree_root_hash":"tbears_does_not_support_merkel_tree","time_stamp":1533719753948440,"confirmed_transaction_list":[{"version":"0x3","from":"hxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6","value":"0x8ac7230489e80000","stepLimit":"0x2000","timestamp":"0x572e8f51e4481","nid":"0x3","nonce":"0x1","to":"hxbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab","signature":"f2B3r27u7peL3I9uBnKA8yn82odqlMECU+UBkRiZTJIwWFo57AmlUjKhoK8OZBBRdaWWmLF+JTZNs70yF8+zIwA="}],"block_hash":"815c0fd7a0dd4594bb19ee39030c1bd91c200878f1f456fe8dd7ff4e0a19b839","height":1,"peer_id":"a6b22354-9aeb-11e8-a0ae-acde48001122","signature":"tbears_does_not_support_signature"},"id":1}tbears consoleDescriptionEnter T-Bears interactive mode using IPython. (Ipython.org)Usageusage:tbearsconsole[-h]GetintotbearsinteractivemodebyembeddingIPython

optionalarguments:-h,--helpshowthishelpmessageandexitExamplesIn the interactive mode, you can execute command in short form (withouttbears) by predefined IPython's magic command.
TAB will complete T-Bears's command or variable names. Use TAB.(work)$tbearsconsole
tbears)start
Startedtbearsservicesuccessfully
...

tbears)balancehxef73db5d0ad02eb1fadb37d0041be96bfa56d4e6

balance:0x0In IPython, you can access previous output using "_" expression.tbears)pwd'/Users/username/working/'tbears)_'/Users/username/working/'You can access nth-output using _n-th expression.
TheOutobject is a dictionary mapping input numbers to their outputs.tbears)'1''1'tbears)'second''second'tbears)33tbears)_2'second'tbears)Out{1:'1',2:'second',3:3,4:'second'}You can pass the value of a variable as an argument by prefixing the variable name with "$".tbears)address=f"hx{'0'*40}"tbears)balance$addressbalance:0x2961fff8ca4a62327800000You should use "{}" expression when you pass a member of list or dictionary.tbears)deploysample_token

Senddeployrequestsuccessfully.
transactionhash:0x541d8c9d3e12d92ad50897f81178301f21650b0b48dd5cc722b28b5c56cbc29a


tbears)txresult{_['result']}{'jsonrpc':'2.0','result':{'txHash':'0xd1ee48aa5d26c1deb275da644e4ffe607c9e556474403c51040dfa59b0dd563c','blockHeight':'0x3',
...In the interactive mode,deployresultscommand is available to list up the SCOREs that have been deployed while T-Bears interactive mode is running.tbears)deployresults1.path:hello/,txhash:0x583a89ec656d71d1641945a39792e016eefd6221ad536f9c312957f0c4336774,deployedin:http://127.0.0.1:9000/api/v32.path:token/,txhash:0x8c2fe3c877d46b7a1ba7feb117d0b12c8b88f33517ad2315ec45e8b7223c22f8,deployedin:http://127.0.0.1:9000/api/v33.path:abctoken/,txhash:0xee6e311d2652fd5ed5981f4906bca5d4d6933400721fcbf3528249d7bf460e42,deployedin:http://127.0.0.1:9000/api/v3T-Bears assigns T-Bears command execution result to '_r' variable.tbears)deploysample_token
Senddeployrequestsuccessfully.
transactionhash:0x5257b44fe0f36c492e255dbfcdb2ca1134dc9a942b875241d01db3d36ac2bdc8

tbears)result=_r

tbears)result{'jsonrpc':'2.0','result':'0x5257b44fe0f36c492e255dbfcdb2ca1134dc9a942b875241d01db3d36ac2bdc8','id':1}tbears)txresult{result['result']}Transactionresult:{"jsonrpc":"2.0","result":{"txHash":"0x5257b44fe0f36c492e255dbfcdb2ca1134dc9a942b875241d01db3d36ac2bdc8","blockHeight":"0x1","blockHash":"9c06e5c1bbd8ed1efc1ec7d1be59b64dd102bde43fc13c3f22e25e5aaa1eda51","txIndex":"0x0","to":"cx0000000000000000000000000000000000000000","scoreAddress":"cxb8f2c9ba48856df2e889d1ee30ff6d2e002651cf",
...

tbears)scoreapi{_r['result']['scoreAddress']}SCOREAPI:[{"type":"fallback","name":"fallback","inputs":[]},
...Configuration Filestbears_server_config.jsonWhen starting T-Bears (tbears start),tbears_server_config.jsonis used to configure the parameters and initial settings.{"hostAddress":"127.0.0.1","port":9000,"scoreRootPath":"./.score","stateDbRootPath":"./.statedb","log":{"logger":"tbears","level":"info","filePath":"./tbears.log","colorLog":true,"outputType":"file","rotate":{"type":"bytes","maxBytes":10485760,"backupCount":10}},"service":{"fee":false,"audit":false,"deployerWhiteList":false},"genesis":{"nid":"0x3","accounts":[{"name":"genesis","address":"hx0000000000000000000000000000000000000000","balance":"0x2961fff8ca4a62327800000"},{"name":"fee_treasury","address":"hx1000000000000000000000000000000000000000","balance":"0x0"},{"name":"test1","address":"hxe7af5fcfd8dfc67530a01a0e403882687528dfcb","balance":"0x2961fff8ca4a62327800000"}]},"blockConfirmInterval":2,"blockConfirmEmpty":true,"mainPRepCount":4,"iissCalculatePeriod":30,"termPeriod":30}FieldData typeDescriptionhostAddressstringIP address that T-Bears service will listen on.portintPort number that T-Bears service will listen on.scoreRootPathstringRoot directory where SCORE will be installed.stateDbRootPathstringRoot directory where state DB file will be created.logdictT-Bears log settinglog.loggerstringMain logger in processlog.levelstringlog level."debug", "info", "warning", "error"log.filePathstringLog file path.log.colorLogbooleanLog display option (color or black)log.outputTypestring“console”: log outputs to the console that T-Bears is running.“file”: log outputs to the file path.“console|file”: log outputs to both console and file.log.rotatedictLog rotate settinglog.rotate.typestring"peroid": rotate by period."bytes": rotate by maxBytes."period|bytes": log rotate to both period and bytes.log.rotate.periodstringuse logging.TimedRotatingFileHandler 'when'ex) daily, weekly, hourly or minutelylog.rotate.intervalstringuse logging.TimedRotatingFileHandler 'interval'ex) (period: hourly, interval: 24) == (period: daily, interval: 1)log.rotate.maxBytesintegeruse logging.RotatingFileHandler 'maxBytes'ex) 10mb == 10 * 1024 * 1024log.rotate.backupCountintegerlimit log file countservicedidctT-Bears service settingservice.feebooleantrue | false. Charge a fee per transaction when enabledservice.auditbooleantrue | false. Audit deploy transactions when enabledservice.deployerWhiteListbooleantrue | false. Limit SCORE deploy permission when enabledgenesisdictGenesis information of T-Bears node.genesis.nidstringNetwork ID.genesis.accountslistList of accounts that holds initial coins.(index 0) genesis: account that holds initial coins.(index 1) fee_treasury: account that collects transaction fees.(index 2~): test accounts that you can add.channelstringchannel name interact with iconrpcserver and iconserviceamqpKeystringamqp key name interact with iconrpcserver and iconserviceamqpTargetstringamqp target name interact with iconrpcserver and iconserviceblockConfirmIntervalintegerConfirm block every N secondsblockConfirmEmptybooleantrue | false. Confirm empty block when enabledmainPRepCountintegerIISS main P-Rep counttermPeriodintegerTerm of main P-Reptbears_cli_config.jsonFor every T-Bears CLI commands exceptstart,stop,clear,initandkeystore, this file is used to configure the default parameters and initial settings.In this configuration file, you can define default options values for some CLI commands. For example, SCORE'son_install()oron_update()method is called on deployment. You can set the deploymodeand the parameters (scoreParams) ofon_install()oron_update()as shown below.{"uri":"http://127.0.0.1:9000/api/v3","nid":"0x3","keyStore":null,"from":"hxe7af5fcfd8dfc67530a01a0e403882687528dfcb","to":"cx0000000000000000000000000000000000000000","deploy":{"mode":"install","scoreParams":{}},"txresult":{},"transfer":{}}FieldData  typeDescriptionuristringURI to send the request.nidstringNetwork ID. 0x3 is reserved for T-Bears.keyStorestringKeystore file path.fromstringFrom address. It is ignored if 'keyStore' is set.tostringTo address.stepLimitstring(optional) stepLimit value.deploydictOptions for deploy command.deploy.modestringDeploy mode.install: new SCORE deployment.update: update the SCORE that was previously deployed.deploy.scoreParamsdictParameters to be passed to on_install() or on_update()deploy.fromstringAddress of the SCORE deployerOptional. This value will override "from" value. If not given, "from" value will be used.deploy.tostringUsed when update SCORE (The address of the SCORE being updated).In the case of "install" mode, the address should be 'cx0000~'.Optional. This value will override "to" value. If not given, "to" value will be used.txresultdictOptions for txresult command.You can define command options in a dict.transferdictOptions for transfer command.You can define command options in a dict.Following CLI commands and options can be defined in the configuration file.CommandOptionsdeployuri, nid, keyStore, from, to, mode, scoreParams, stepLimittransferuri, nid, keyStore, from, stepLimitsendtxuri, nid, keyStore, from, stepLimittxresultbalancetotalsupplyscoreapitxbyhashlastblockblockbyhashblockbyheightcallurikeystore fileskeystore_test1
Keystore file for the test account. Password of this keystore file istest1_Account.
You can find the test account 'test1' intbears_server_config.jsonand this test account has enough balance to test on local environment.Do not transfer any ICX or tokens to 'test1' account.prepN_keystore
Keystore files for the main P-Rep. Password of these keystore files areprepN_Account.sync_mainnetcommand makes 4 main P-Reps and you can manage these 4 main P-Rep accounts with prepN_keystore files.ReferencesICON JSON-RPC API v3earlgreyICON CommonsICON RPC ServerICON ServiceSCORE integration TestLicenseThis project follows the Apache 2.0 License. Please refer toLICENSEfor details.