Skip to content

Commit 3984ad9

Browse files
authored
Merge pull request #1128 from Concordium/doc2-tutorials-sponsoredTransactions
Added more references, explanations and formatted commands
2 parents 7dd78a2 + f1f6422 commit 3984ad9

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

source/mainnet/tutorials/sponsoredTransactions/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ What is the difference between a normal transaction vs. a sponsored transaction?
4747

4848
A normal transaction sent to a smart contract is signed by the user's wallet and authorizes the blockchain to subtract the transaction fee from the user's wallet as well as to execute a specific action. For example, the action could be to transfer some tokens from the user's address to another address.
4949

50-
The user creates a normal transaction by signing its ``account`` address, its ``nonce``, and the ``action``. The ``nonce`` increases sequentially every time the user sends a transaction to the blockchain to prevent replay attacks. The nonce is of type u64 (8 bytes) and by design >= 1.
50+
The user creates a normal transaction by signing its ``account`` address, its ``nonce``, and the ``action``. The ``nonce`` increases sequentially every time the user sends a transaction to the blockchain to prevent replay attacks. The `nonce <https://en.wikipedia.org/wiki/Cryptographic_nonce>`_ is of type u64 (8 bytes) and by design >= 1.
5151

5252
.. image:: ./images/NormalSmartContractTransactionFlow.png
5353
:alt: Normal Smart Contract Transaction Flow

source/mainnet/tutorials/sponsoredTransactions/sponsoredTransactionsSmartContract.rst

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ The goal of this part of the tutorial is to understand how the sponsored
99
transaction mechanism is implemented in the smart contract and how to create and verify an Ed25519 signature in the smart contract code.
1010

1111
Clone the `sponsored transaction example <https://github.com/Concordium/concordium-rust-smart-contracts/tree/main/examples/cis3-nft-sponsored-txs>`_
12-
which you will modify in this tutorial.
12+
which you will modify in this tutorial. The ``recurse-submodules`` flag is needed because the git repository contains `submodules <https://git-scm.com/book/en/v2/Git-Tools-Submodules>`_ which need to be cloned along with the example.
1313

1414
.. code-block:: console
1515
16-
$git clone --recurse-submodules [email protected]:Concordium/concordium-rust-smart-contracts.git
16+
$ git clone --recurse-submodules [email protected]:Concordium/concordium-rust-smart-contracts.git
1717
1818
Navigate to the correct example folder:
1919

2020
.. code-block:: console
2121
22-
$cd ./examples/cis3-nft-sponsored-txs
22+
$ cd ./examples/cis3-nft-sponsored-txs
2323
2424
The ``cis3_nft`` contract implements the `CIS-3 standard (sponsored transactions) <https://proposals.concordium.software/CIS/cis-3.html>`_. The standard defines that the contract has to expose the
2525
``permit`` and the ``supportsPermit`` functions.
@@ -79,7 +79,9 @@ You can explore the function by invoking it with the ``concordium-client`` as fo
7979

8080
.. code-block:: console
8181
82-
$concordium-client contract invoke 6372 --entrypoint supportsPermit --parameter-json supportsPermit.json --grpc-port 20000 --grpc-ip node.testnet.concordium.com
82+
$ concordium-client contract invoke 6372 --entrypoint supportsPermit --parameter-json supportsPermit.json --grpc-port 20000 --grpc-ip node.testnet.concordium.com
83+
84+
``6372`` is the index of the smart contract. A smart contract address consists of an index and a subindex, in the current protocol the subindex will always be 0. So, in other words, the command above means invoke contract with index 6372 on the testnet.
8385

8486
For example, this ``supportsPermit.json`` file results in the below screenshot.
8587

@@ -120,9 +122,9 @@ Run the test cases to confirm that they pass before you start modifying the code
120122

121123
.. code-block:: console
122124
123-
$cargo test
125+
$ cargo test
124126
or
125-
$cargo concordium test
127+
$ cargo concordium test
126128
127129
.. image:: ./images/testCases.png
128130
:alt: Running the test cases
@@ -146,7 +148,9 @@ This prints the ``message_hash`` when running the test cases as follows:
146148

147149
.. code-block:: console
148150
149-
$cargo test -- --nocapture
151+
$ cargo test -- --nocapture
152+
153+
To learn more about the ``nocapture`` flag you can follow `this link <https://doc.rust-lang.org/cargo/commands/cargo-test.html#display-options>`_
150154

151155
.. image:: ./images/messageHash.png
152156
:alt: Printing the message hash
@@ -184,13 +188,13 @@ Add the above code snippet to the top of a test case and run the test cases agai
184188

185189
.. code-block:: console
186190
187-
$cargo test -- --nocapture
191+
$ cargo test -- --nocapture
188192
189193
The output should look similar to:
190194

191195
.. code-block:: console
192196
193-
$signature: [252, 135, 206, 148, 151, 203, 217, 221, 223, 182, 206, 211, 25, 20, 212, 251, 147, 221, 21, 142, 239, 231, 175, 146, 122, 179, 27, 180, 113, 120, 230, 26, 51, 190, 165, 37, 104, 71, 92, 22, 30, 197, 183, 165, 232, 107, 159, 95, 2, 116, 39, 65, 146, 102, 93, 131, 25, 124, 76, 233, 162, 76, 124, 6]
197+
$ signature: [252, 135, 206, 148, 151, 203, 217, 221, 223, 182, 206, 211, 25, 20, 212, 251, 147, 221, 21, 142, 239, 231, 175, 146, 122, 179, 27, 180, 113, 120, 230, 26, 51, 190, 165, 37, 104, 71, 92, 22, 30, 197, 183, 165, 232, 107, 159, 95, 2, 116, 39, 65, 146, 102, 93, 131, 25, 124, 76, 233, 162, 76, 124, 6]
194198
195199
You can create the below signature constant. This signature can be used in test cases to check if your signature verification logic in the smart contract works.
196200

@@ -209,13 +213,13 @@ Add the above code snippet to the top of a test case and run the test cases agai
209213

210214
.. code-block:: console
211215
212-
$cargo test -- --nocapture
216+
$ cargo test -- --nocapture
213217
214218
The output should look similar to:
215219

216220
.. code-block:: console
217221
218-
$public_key: [135, 40, 213, 241, 57, 171, 239, 135, 24, 139, 191, 24, 185, 167, 91, 78, 39, 223, 129, 189, 107, 201, 204, 27, 117, 130, 160, 157, 116, 188, 60, 136]
222+
$ public_key: [135, 40, 213, 241, 57, 171, 239, 135, 24, 139, 191, 24, 185, 167, 91, 78, 39, 223, 129, 189, 107, 201, 204, 27, 117, 130, 160, 157, 116, 188, 60, 136]
219223
220224
You can create the below public key constant. This public key can be used in test cases to check if your signature verification logic in the smart contract works.
221225

0 commit comments

Comments
 (0)