You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: source/CIS/cis-5.rst
+25-21
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ CIS-5: Smart Contract Wallet Standard
9
9
10
10
* - Created
11
11
- Mar 17, 2024
12
+
* - Final
13
+
- May 23, 2024
12
14
* - Supported versions
13
15
- | Smart contract version 1 or newer
14
16
|(Protocol version 4 or newer)
@@ -24,10 +26,10 @@ A standard interface for defining a smart contract wallet that can hold and tran
24
26
CCDs/CIS-2 tokens can be deposited into the smart contract wallet by
25
27
specifying to which public key the deposit should be assigned.
26
28
27
-
The holder of the corresponding private key does not have to submit transactions
29
+
The holder of the corresponding private key does not submit transactions
28
30
on chain to transfer/withdraw its CCD/CIS-2 token balances,
29
31
but instead, it can generate a valid signature, identify a willing third
30
-
party to submit its signature on-chain (a service fee can be added to financially incentivize a third party to do so).
32
+
party to submit its signature in a transaction on-chain (a service fee can be added to financially incentivize a third party to do so).
31
33
32
34
The three main actions in the smart contract that can be taken:
33
35
@@ -37,8 +39,9 @@ The three main actions in the smart contract that can be taken:
37
39
38
40
- *withdraw*: withdraws the balance out of the smart contract wallet to a native account or smart contract.
39
41
40
-
The goal of this standard is to simplify the account creation onboarding flow on Concordium
41
-
allowing for CIS-5 smart contract wallets to be supported as first-class citizens in Concordium wallets and tooling.
42
+
The goal of this standard is to create an alternative simplified onboarding flow
43
+
without the inconvenience of a native account creation on Concordium.
44
+
Allowing for CIS-5 smart contract wallets to be supported as first-class citizens in Concordium wallets and tooling.
42
45
43
46
Specification
44
47
=============
@@ -57,6 +60,7 @@ General types and serialization
57
60
``TokenID``
58
61
^^^^^^^^^^^
59
62
63
+
The token ID is from the CIS-2 standard :ref:`CIS-2-TokenID`.
60
64
A token ID is serialized as 1 byte for the size (``n``) of the identifier, followed by this number of bytes for the token id (``id``)::
61
65
62
66
TokenID ::= (n: Byte) (id: Byteⁿ)
@@ -66,6 +70,7 @@ A token ID is serialized as 1 byte for the size (``n``) of the identifier, follo
66
70
``TokenAmount``
67
71
^^^^^^^^^^^^^^^
68
72
73
+
The token amount is from the CIS-2 standard :ref:`CIS-2-TokenAmount`.
69
74
It is serialized using the LEB128_ variable-length unsigned integer encoding, with the additional constraint that the total number of bytes of the encoding MUST not exceed 37 bytes::
70
75
71
76
TokenAmount ::= (x: Byte) => x if x < 2^7
@@ -220,7 +225,7 @@ The ``NonceEvent`` is serialized as: First a byte with the value of 250, followe
220
225
``DepositCcdEvent``
221
226
^^^^^^^^^^^^^^^^^^^
222
227
223
-
A ``DepositCcdEvent`` SHALL be logged ever time an amount of CCD received by the contract is assigned to a public key.
228
+
A ``DepositCcdEvent`` SHALL be logged every time an amount of CCD received by the contract is assigned to a public key.
224
229
225
230
The ``DepositCcdEvent`` is serialized as: First a byte with the value of 249, followed by the :ref:`CIS-5-CCDAmount` (``ccdAmount``), the :ref:`CIS-5-Address` (``from``), and a :ref:`CIS-5-PublicKeyEd25519` (``to``)::
226
231
@@ -229,7 +234,7 @@ The ``DepositCcdEvent`` is serialized as: First a byte with the value of 249, fo
229
234
``DepositCis2TokensEvent``
230
235
^^^^^^^^^^^^^^^^^^^^^^^^^^
231
236
232
-
A ``DepositCis2TokensEvent`` SHALL be logged ever time a token amount received by the contract is assigned to a public key.
237
+
A ``DepositCis2TokensEvent`` SHALL be logged every time a token amount received by the contract is assigned to a public key.
233
238
234
239
The ``DepositCis2TokensEvent`` is serialized as: First a byte with the value of 248, followed by the
@@ -240,7 +245,7 @@ The ``DepositCis2TokensEvent`` is serialized as: First a byte with the value of
240
245
``WithdrawCcdEvent``
241
246
^^^^^^^^^^^^^^^^^^^^
242
247
243
-
A ``WithdrawCcdEvent`` SHALL be logged ever time an amount of CCD held by a public key is withdrawn to an address.
248
+
A ``WithdrawCcdEvent`` SHALL be logged every time an amount of CCD held by a public key is withdrawn to an address.
244
249
245
250
The ``WithdrawCcdEvent`` is serialized as: First a byte with the value of 247, followed by the :ref:`CIS-5-CCDAmount` (``ccdAmount``), a :ref:`CIS-5-PublicKeyEd25519` (``from``), and the :ref:`CIS-5-Address` (``to``)::
246
251
@@ -249,7 +254,7 @@ The ``WithdrawCcdEvent`` is serialized as: First a byte with the value of 247, f
249
254
``WithdrawCis2TokensEvent``
250
255
^^^^^^^^^^^^^^^^^^^^^^^^^^^
251
256
252
-
A ``WithdrawCis2TokensEvent`` SHALL be logged ever time a token amount held by a public key is withdrawn to an address.
257
+
A ``WithdrawCis2TokensEvent`` SHALL be logged every time a token amount held by a public key is withdrawn to an address.
253
258
254
259
The ``WithdrawCis2TokensEvent`` is serialized as: First a byte with the value of 246, followed by the
@@ -260,7 +265,7 @@ The ``WithdrawCis2TokensEvent`` is serialized as: First a byte with the value of
260
265
``TransferCcdEvent``
261
266
^^^^^^^^^^^^^^^^^^^^
262
267
263
-
A ``TransferCcdEvent`` SHALL be logged ever time an amount of CCD held by a public key is transferred to another public key within the contract.
268
+
A ``TransferCcdEvent`` SHALL be logged every time an amount of CCD held by a public key is transferred to another public key within the contract.
264
269
265
270
The ``TransferCcdEvent`` is serialized as: First a byte with the value of 245, followed by the :ref:`CIS-5-CCDAmount` (``ccdAmount``), a :ref:`CIS-5-PublicKeyEd25519` (``from``), and the :ref:`CIS-5-PublicKeyEd25519` (``to``)::
266
271
@@ -269,7 +274,7 @@ The ``TransferCcdEvent`` is serialized as: First a byte with the value of 245, f
269
274
``TransferCis2TokensEvent``
270
275
^^^^^^^^^^^^^^^^^^^^^^^^^^^
271
276
272
-
A ``TransferCis2TokensEvent`` SHALL be logged ever time a token amount held by a public key is transferred to another public key within the contract.
277
+
A ``TransferCis2TokensEvent`` SHALL be logged every time a token amount held by a public key is transferred to another public key within the contract.
273
278
274
279
The ``TransferCis2TokensEvent`` is serialized as: First a byte with the value of 244, followed by the
@@ -279,7 +284,7 @@ The ``TransferCis2TokensEvent`` is serialized as: First a byte with the value of
279
284
280
285
.. note::
281
286
282
-
The CIS-5 events SHALL enable off-chain applications to compute off-chain all balances that the public keys are holding.
287
+
The collection of all CIS-5 events emitted by a smart contract instance implementing CIS-5 SHALL enable off-chain applications to compute off-chain all non-zero balances that the public keys are holding.
283
288
284
289
.. _CIS-5-functions:
285
290
@@ -359,13 +364,13 @@ It is serialized as: 2 bytes representing the number of withdrawals (``n``) foll
359
364
360
365
Each ``WithdrawBatchCcdAmount`` is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``), and a ``WithdrawMessageCcdAmount`` (``message``).
361
366
362
-
Each ``WithdrawMessageCcdAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), 2 bytes representing the number of simple withdraws (``m``) followed by the bytes for this number of simple withdraws (``simpleWithdraws``).
367
+
Each ``WithdrawMessageCcdAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-Timestamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), 2 bytes representing the number of simple withdraws (``m``) followed by the bytes for this number of simple withdraws (``simpleWithdraws``).
363
368
364
369
Each ``WithdrawCcdAmount`` is serialized as: the receiving address :ref:`CIS-2-Receiver` (``to``), the :ref:`CIS-5-CCDAmount` (``withdrawAmount``), and some additional data :ref:`CIS-2-AdditionalData` (``data``)::
Be aware of transferring CCDs to a non-existing account address or contract address.
410
-
This specification by itself does not include a standard that has to be followed.
414
+
Be aware of transferring CCDs to a non-existing account address or contract address which results in an error on Concordium.
411
415
Checking the existence of an account address/ contract address would ideally be done off-chain before the message is even sent to the smart contract.
412
416
413
417
.. _CIS-5-functions-withdrawCis2Tokens:
@@ -427,13 +431,13 @@ It is serialized as: 2 bytes representing the number of withdrawals (``n``) foll
427
431
428
432
Each ``WithdrawBatchTokenAmount`` is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``), and a ``WithdrawMessageTokenAmount`` (``message``).
429
433
430
-
Each ``WithdrawMessageTokenAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-ExternalTokenAmount` (``serviceFee``), 2 bytes representing the number of simple withdraws (``m``) followed by the bytes for this number of simple withdraws (``simpleWithdraws``).
434
+
Each ``WithdrawMessageTokenAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-Timestamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-ExternalTokenAmount` (``serviceFee``), 2 bytes representing the number of simple withdraws (``m``) followed by the bytes for this number of simple withdraws (``simpleWithdraws``).
431
435
432
436
Each ``WithdrawTokenAmount`` is serialized as: the receiving address :ref:`CIS-2-Receiver` (``to``), the :ref:`CIS-5-ExternalTokenAmount` (``withdrawAmount``), and some additional data :ref:`CIS-2-AdditionalData` (``data``)::
@@ -475,13 +479,13 @@ It is serialized as: 2 bytes representing the number of transfers (``n``) follow
475
479
476
480
Each ``TransferBatchCcdAmount`` is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``), and a ``TransferMessageCcdAmount`` (``message``).
477
481
478
-
Each ``TransferMessageCcdAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), 2 bytes representing the number of simple transfers (``m``) followed by the bytes for this number of simple transers (``simpleTransfers``).
482
+
Each ``TransferMessageCcdAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-Timestamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), 2 bytes representing the number of simple transfers (``m``) followed by the bytes for this number of simple transers (``simpleTransfers``).
479
483
480
484
Each ``TransferCcdAmount`` is serialized as: the receiving :ref:`CIS-5-PublicKeyEd25519` (``to``), and the :ref:`CIS-5-CCDAmount` (``transferAmount``)::
@@ -520,13 +524,13 @@ It is serialized as: 2 bytes representing the number of transfers (``n``) follow
520
524
521
525
Each ``TransferBatchTokenAmount`` is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``), and a ``TransferMessageTokenAmount`` (``message``).
522
526
523
-
Each ``TransferMessageTokenAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-ExternalTokenAmount` (``serviceFee``), 2 bytes representing the number of simple transfers (``m``) followed by the bytes for this number of simple transfers (``simpleTransfers``).
527
+
Each ``TransferMessageTokenAmount`` is serialized as: an :ref:`CIS-5-EntrypointName` (``entryPoint``), a :ref:`CIS-5-Timestamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-PublicKeyEd25519` (``serviceFeeRecipient``), a :ref:`CIS-5-ExternalTokenAmount` (``serviceFee``), 2 bytes representing the number of simple transfers (``m``) followed by the bytes for this number of simple transfers (``simpleTransfers``).
524
528
525
529
Each ``TransferTokenAmount`` is serialized as: the receiving :ref:`CIS-5-PublicKeyEd25519` (``to``), the :ref:`CIS-5-ExternalTokenAmount` (``transferAmount``)::
0 commit comments