tonos-cli
is a command line interface utility designed to work with TON blockchain.
- Rust >= 1.43.x installed
cargo update
cargo build [--release] [-j8]
cargo test -- --test-threads 1
cargo run [subcommand args]
> cd ./target/release
> ./tonos-cli [subcommand args]
By default, tonos-cli connects to https://net.ton.dev
network.
tonos-cli genphrase
tonos-cli genpubkey
tonos-cli getkeypair <keyfile.json> "<seed_phrase>"
tonos-cli getconfig <index>
tonos-cli genaddr [--genkey|--setkey <keyfile.json>] <tvc> <abi>
Example: tonos-cli genaddr --genkey wallet_keys.json wallet.tvc wallet.abi.json
wallet_keys.json
file will be created with new keypair.
tonos-cli deploy [--sign <keyfile>] [--wc <int8>] [--abi <abifile>] <tvc> <params>
Example: tonos-cli deploy --abi wallet.abi.json --sign wallet_keys.json wallet.tvc {param1:0}
If --abi
or --sign
option is omitted in parameters it must present in config file. See below.
Call contract in blockchain:
tonos-cli call [--abi <abi_file>] [--sign <keyfile>] <address> <method> <params>
If --abi
or --sign
option is omitted in parameters, it must be specified in the config file. See below for more details.
Alternative command:
tonos-cli callex <method> [<address>] [<abi>] [<keys>] params...
params...
- one or more function arguments in the form of --name value
.
address
, abi
, and keys
parameters can be omitted. In this case default values will be used from config file.
Example:
tonos-cli callex submitTransaction 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e SafeMultisigWallet.abi.json msig.keys.json --dest 0:c63a050fe333fac24750e90e4c6056c477a2526f6217b5b519853c30495882c9 --value 1.5T --bounce false --allBalance false --payload ""
Integer and address types can be supplied without quotes.
--value 1.5T
- suffix T
converts integer to nanotokens -> 1500000000
. The same as --value 1500000000
.
Arrays can be used without []
brackets.
Run contract method locally:
tonos-cli run [--abi <abi_file>] <address> <method> <params>
If --abi
option is omitted in parameters, it must be specified in the config file. See below for more details.
Run funC get-method:
tonos-cli runget <address> <method> [<params>...]
params
can have multiple values: one for each function parameter. Example:
tonos-cli runget -1:3333333333333333333333333333333333333333333333333333333333333333 compute_returned_stake 0x4107f968dc3caf85c2aa4e7d1b842d835d743855f62afe87e5862012be3eff4f
tonos-cli runget -1:3333333333333333333333333333333333333333333333333333333333333333 active_election_id
tonos-cli message [--abi <abi_file>] [--sign <keyfile>] <address> <method> <params> [--lifetime <seconds>] [--raw] [--output <file_name>]
Generates external inbound message for account and prints it to terminal or stores to file.
--raw
- generates raw boc message. Can be sent later using sendfile
command.
--output
- saves generates message to specified file instead of printing it to the terminal.
Other parameters are the same as in call
command.
tonos-cli send [--abi <abi_file>] <message>
Allows to send message generated by message
command without --raw
flag.
tonos-cli sendfile <msg_file>
Allows to send external message serialized as bag of cells and stored in specified msg_file
.
tonos-cli can remember some parameter values and use it automatically in all subcommands.
tonos-cli config [--url <url>] [--abi <abifile>] [--keys <keysfile>]
Example: tonos-cli config --url https://main.ton.dev --abi wallet.abi.json --keys wallet_keys.json
After that you can omit --abi
and --sign
parameters in deploy
, call
and run
subcommands and cli by default will connect to main.ton.dev network.
config
command creates config file in current working directory which will be used by cli at every start. To override searching config file in current dir use the following methods:
- define environment variable
TONOSCLI_CONFIG
with path to your config file; - define global option
--config <path_to_file>
before any other subcommand (example:tonos-cli --config ../config.json call ...
).
Global option has higher priority than env variable.
Also you can explicitly define network in every subcommand by using global option --url <network>
(example: tonos-cli --url https://main.ton.dev account <address>
).
tonos-cli account <address>
Example: tonos-cli account 0:c63a050fe333fac24750e90e4c6056c477a2526f6217b5b519853c30495882c9
Task scope: deploy a contract to TON Labs testnet at net.ton.dev.
tonos-cli genaddr contract.tvc --genkey contract_keys.json
Save Raw address
printed to stdout.
Note: You have to get giver address, abi and keys.
Let's request 10 Grams to our account.
tonos-cli call --abi giver.abi.json --sign giver_keys.json <giver_address> sendTransaction {"dest":"<our_address>","value":10000000000,"bounce":false}
tonos-cli account <raw_address>
tonos-cli deploy --abi contract.abi.json --sign contract_keys.json contract.tvc {<constructor_arguments>}
tonos-cli account <raw_address>
The contract should be in the Active
state.
tonos-cli call --abi contract.abi.json --sign contract_keys.json <raw_address> methodName {<method_args>}
Tonos-cli allows to communicate with depool contract using multisignature wallet. All depool commands are started with tonos-cli depool
.
For all commands:
--addr
- address of depool.
--wallet
- address of multisig wallet.
--sign
- path to keyfile or seed phrase of multisig wallet.
All commands allow to omit --addr
, --wallet
and --sign
options only if this values are defined in config file:
tonos-cli config --addr <address> --wallet <address> --keys <path_to_keys or seed_phrase>
all --value
parameters must be defined in tons, like this: --value 10.5
, it means value is 10,5 tons.
tonos-cli depool [--addr <depool_address>] stake ordinary [--wallet <msig_address>] --value <number> [--sign <key_file or seed_phrase>]
tonos-cli depool [--addr <depool_address>] stake vesting [--wallet <msig_address>] --value <number> --total <days> --withdrawal <days> --beneficiary <address> [--sign <key_file or seed_phrase>]
tonos-cli depool [--addr <depool_address>] stake lock [--wallet <msig_address>] --value <number> --total <days> --withdrawal <days> --beneficiary <address> [--sign <key_file or seed_phrase>]
tonos-cli depool [--addr <depool_address>] stake remove [--wallet <msig_address>] --value <number> [--from-round <number>] [--sign <key_file or seed_phrase>]
tonos-cli depool [--addr <depool_address>] stake transfer [--wallet <msig_address>] --value <number> --dest <address> [--sign <key_file or seed_phrase>]
tonos-cli depool [--addr <depool_address>] withdraw on | off [--wallet <msig_address>] [--sign <key_file or seed_phrase>]
tonos-cli depool [--addr <depool_address>] events [--since <utime>]
Prints depool events since defined unixtime. if --since
is omitted then prints all depool events.
tonos-cli depool [--addr <depool_address>] events --wait-one
Waits until new event will be emitted and then prints it to the stdout.
Transfers funds from the multisignature wallet to the depool contract (NOT A STAKE).
tonos-cli depool [--addr <depool_address>] replenish --value <number> [--wallet <msig_address>] [--sign <key_file or seed_phrase>]