3.3.1. CLI guide: sending your first transactions and queries¶
You can interact with Iroha using various ways.
You can use our client libraries
Swift) which communicates with Iroha.
Alternatively, you can use
iroha-cli – our command-line tool for interacting with Iroha.
As a part of this guide, let’s get familiar with
iroha-cli is arguably the simplest way to start working with Iroha,
iroha-cli covers only some possible commands/queries, so user experience might not be the best.
If you want to help us build a better CLI version please let us know!
Open a new terminal (note that Iroha container and
irohad should be up and
running) and attach to an
iroha docker container:
docker exec -it iroha /bin/bash
Now you are in the interactive shell of Iroha’s container again.
We need to launch
iroha-cli and pass an account name of the desired user.
In our example, the account
admin is already created in the
Let’s use this account to work with Iroha.
iroha-cli -account_name admin@test
Full account name has a
@ symbol between name and domain.
Note that the keypair has the same name.
126.96.36.199. Creating the First Transaction¶
You can see the interface of
Let’s create a new asset, add some asset to the admin account and transfer it to other account.
To achieve this, please choose option
1. New transaction (tx) by writing
1 to a console.
Now you can see a list of available commands.
Let’s try creating a new asset.
14. Create Asset (crt_ast).
Now enter a name for your asset, for example
Next, enter a Domain ID. In our example we already have a domain
test, so let’s use it.
Then we need to enter an asset precision
– the amount of numbers in a fractional part.
Let’s set precision to
Congratulations, you have created your first command and added it to a transaction!
You can either send it to Iroha or add some more commands
1. Add one more command to the transaction (add).
Let’s add more commands, so we can do everything in one shot. Type
Now try adding some
coolcoins to our account.
16. Add Asset Quantity (add_ast_qty), enter asset ID –
integer part and
coolcoin#test, integer part and precision.
For example, to add 200.50 precision.
For example, to add 200.50
coolcoins, we need to enter integer
we need to enter integer part as
20050 and precision as part as
and precision as
2, so it becomes
Full asset name has a
# symbol between name and domain.
Let’s transfer 100.50
by adding one more command and choosing
5. Transfer Assets (tran_ast).
Enter Source Account and Destination Account, in our case
test@test, Asset ID (
coolcoin#test), integer part and precision (
Now we need to send our transaction to Iroha peer (
2. Send to Iroha peer (send)).
Enter peer address (in our case
localhost) and port (
Now your transaction is submitted and you can see your transaction hash.
You can use it to check transaction’s status.
Go back to a terminal where
irohad is running.
You can see logs of your transaction.
Yay! You have submitted your first transaction to Iroha.
188.8.131.52. Creating the First Query¶
Now let’s check if
coolcoins were successfully transferred from
2. New query (qry).
8. Get Account's Assets (get_acc_ast) can help you to check if
test@test now has
Form a query in a similar way you did with commands you did with commands and
1. Send to Iroha peer (send).
Now you can see information about how many
It will look similar to this:
[2018-03-21 12:33:23.179275525][th:36][info] QueryResponseHandler [Account Assets] [2018-03-21 12:33:23.179329199][th:36][info] QueryResponseHandler -Account Id:- test@test [2018-03-21 12:33:23.179338394][th:36][info] QueryResponseHandler -Asset Id- coolcoin#test [2018-03-21 12:33:23.179387969][th:36][info] QueryResponseHandler -Balance- 100.50
Isn’t that awesome? You have submitted your first query to Iroha and got a response!
To get information about all available commands and queries please check our API section.
184.108.40.206. Being Badass¶
Let’s try being badass and cheat Iroha. For example, let’s transfer more
Try to transfer 100000.00
Again, proceed to
1. New transaction (tx),
5. Transfer Assets (tran_ast),
enter Source Account and Destination Account, in our case
test@test, Asset ID (
integer part and precision (
Send a transaction to Iroha peer as you did before.
Well, it says
[2018-03-21 12:58:40.791297963][th:520][info] TransactionResponseHandler Transaction successfully sent Congratulation, your transaction was accepted for processing. Its hash is fc1c23f2de1b6fccbfe1166805e31697118b57d7bb5b1f583f2d96e78f60c241
Your transaction was accepted for processing.
Does it mean that we had successfully cheated Iroha?
Let’s try to see transaction’s status.
3. New transaction status request (st) and enter transaction’s hash which you can get in the console after the previous command.
Let’s send it to Iroha.
It replies with:
Transaction has not passed stateful validation.
Our transaction was not accepted because it did not pass stateful validation and
coolcoins were not transferred.
You can check the status of
test@test with queries to be sure (like we did earlier).