Coder Social home page Coder Social logo

tonos-cli's Introduction

TON OS command line tool

tonos-cli is a command line interface utility designed to work with TON blockchain.

How to build

cargo build [--release]

How to test

cargo test

How to run

Default

cargo run [subcommand args]

Linux

> cd ./target/release

> ./tonos-cli [subcommand args]

How to use

By default, tonos-cli connects to https://net.ton.dev network.

Crypto commands:

1) Generate seed phrase

tonos-cli genphrase

2) Generate pubkey from seed phrase

tonos-cli genpubkey

Smart contract commands:

1) Generate Contract Address

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.

2) Deploy Smart Contract

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.

3) Call Method

tonos-cli call [--abi <abi_file>] [--sign <keyfile>] <address> <method> <params>

Run get-method:

tonos-cli run [--abi <abi_file>] <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.

4) Generate signed message

tonos-cli message [--abi <abi_file>] [--sign <keyfile>] <address> <method> <params> [--lifetime <seconds>]

5) Send prepared message

tonos-cli send [--abi <abi_file>] <message>

6) Store Parameter Values in the Configuration File

tonos-cli can remember some parameter values and use it automatically in deploy, call and run subcommands.

tonos-cli config [--url <url>] [--abi <abifile>] [--keys <keysfile>]

Example: tonos-cli config --abi wallet.abi.json --keys wallet_keys.json

After that you can omit --abi and --sign parameters in deploy, call and run subcommands.

7) Get Account Info

tonos-cli account <address>

Example: tonos-cli account 0:c63a050fe333fac24750e90e4c6056c477a2526f6217b5b519853c30495882c9

Sample Test Sequence

Task scope: deploy a contract to TON Labs testnet at net.ton.dev.

1) compile contract and get .tvc file and .abi.json. Lets name it contract.tvc.

2) generate contract address.

tonos-cli genaddr contract.tvc --genkey contract_keys.json

Save Raw address printed to stdout.

3) Ask the testnet giver for Grams.

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}

4) Get our contract state, check that it is created in blockchain and has the Uninit state.

tonos-cli account <raw_address>

5) Deploy our contract to the testnet.

tonos-cli deploy --abi contract.abi.json --sign contract_keys.json contract.tvc {<constructor_arguments>}

6) Check the contract state.

tonos-cli account <raw_address>

The contract should be in the Active state.

7) Use the call subcommand to execute contract methods in blockchain.

tonos-cli call --abi contract.abi.json --sign contract_keys.json <raw_address> methodName {<method_args>}

tonos-cli's People

Contributors

keshoid avatar ar-tmp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.