This repository was archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 294
Change getting started structure #2175
Draft
neewy
wants to merge
2
commits into
develop
Choose a base branch
from
docs/update-getting-started
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _core-concepts: | ||
|
||
Core concepts | ||
============= | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
CLI guide: sending your first transactions and queries | ||
====================================================== | ||
|
||
You can interact with Iroha using various ways. You can use our client libraries | ||
to write code in various programming languages (e.g. Java, Python, Javascript, | ||
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`` | ||
|
||
.. Attention:: Despite that ``iroha-cli`` is arguably the simplest way to start | ||
working with Iroha, ``iroha-cli`` was engineered very fast and lacks tests, | ||
so user experience might not be the best. For example, the order of menu items | ||
LiraLemur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
can differ from that you see in this guide. In the future, we will deliver a | ||
better version and appreciate contributions. | ||
LiraLemur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. raw:: html | ||
|
||
<script src="https://asciinema.org/a/6dFA3CWHQOgaYbKfQXtzApDob.js" id="asciicast-6dFA3CWHQOgaYbKfQXtzApDob" async></script> | ||
|
||
Open a new terminal (note that Iroha container and ``irohad`` should be up and | ||
running) and attach to an ``iroha`` docker container: | ||
|
||
.. code-block:: shell | ||
|
||
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 a ``test`` domain. Let's use this | ||
LiraLemur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
account to work with Iroha. | ||
|
||
.. code-block:: shell | ||
|
||
iroha-cli -account_name admin@test | ||
|
||
.. note:: Full account name has a ``@`` symbol between name and domain. Note | ||
that the keypair has the same name. | ||
|
||
Creating the First Transaction | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
You can see the interface of ``iroha-cli`` now. 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 ``tx`` or | ||
``1`` to a console. | ||
|
||
Now you can see a list of available commands. Let's try creating a new asset. | ||
Select ``14. Create Asset (crt_ast)``. Now enter a name for your asset, for | ||
example ``coolcoin``. 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 ``2``. | ||
|
||
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 ``add``. | ||
|
||
Now try adding some ``coolcoins`` to our account. Select ``16. Add Asset | ||
Quantity (add_ast_qty)``, enter Account ID – ``admin@test``, asset ID – | ||
``coolcoin#test``, integer part and precision. For example, to add 200.50 | ||
``coolcoins``, we need to enter integer part as ``20050`` and precision as | ||
``2``, so it becomes ``200.50``. | ||
|
||
.. note:: Full asset name has a ``#`` symbol between name and domain. | ||
|
||
Let's transfer 100.50 ``coolcoins`` from ``admin@test`` to ``test@test`` | ||
by adding one more command and choosing ``5. Transfer Assets (tran_ast)``. | ||
Enter Source Account and Destination Account, in our case ``admin@test`` and | ||
``test@test``, Asset ID (``coolcoin#test``), integer part and precision | ||
(``10050`` and ``2`` accordingly). | ||
|
||
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 (``50051``). | ||
Congratulations, 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. | ||
|
||
Congratulations! You have submitted your first transaction to Iroha. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too many congratulations. Can we replace some of them with .. (idk what will be the best replacement)? |
||
|
||
Creating the First Query | ||
^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Now let's check if ``coolcoins`` were successfully transferred from | ||
``admin@test`` to ``test@test``. Choose ``2. New query | ||
(qry)``. ``7. Get Account's Assets (get_acc_ast)`` can help you to check if | ||
``test@test`` now has ``coolcoin``. 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 ``coolcoin`` does ``test@test`` have. | ||
It will look similar to this: | ||
|
||
.. code:: | ||
|
||
[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`` | ||
|
||
Congratulations! You have submitted your first query to Iroha and got a | ||
LiraLemur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
response! | ||
|
||
.. hint:: To get information about all available commands and queries | ||
please check our API section. | ||
|
||
Being Badass | ||
^^^^^^^^^^^^ | ||
|
||
Let's try being badass and cheat Iroha. For example, let's transfer more | ||
``coolcoins`` than ``admin@test`` has. Try to transfer 100000.00 ``coolcoins`` | ||
from ``admin@test`` to ``test@test``. Again, proceed to ``1. New transaction | ||
(tx)``, ``5. Transfer Assets (tran_ast)``, enter Source Account and Destination | ||
Account, in our case ``admin@test`` and ``test@test``, Asset ID | ||
(``coolcoin#test``), integer part and precision (``10000000`` and ``2`` | ||
accordingly). Send a transaction to Iroha peer as you did before. Well, it says | ||
|
||
.. code:: | ||
|
||
[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. Choose | ||
``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: | ||
|
||
.. code:: | ||
|
||
Transaction has not passed stateful validation. | ||
|
||
Apparently no. Our transaction was not accepted because it did not pass | ||
stateful validation and ``coolcoins`` were not transferred. You can check | ||
the status of ``admin@test`` and ``test@test`` with queries to be sure | ||
(like we did earlier). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.