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
A standard interface for defining a smart contract wallet that can hold and transfer native currency and cis2 tokens.
26
-
Native currency/Cis2 tokens can be deposited into the smart contract wallet by
25
+
A standard interface for defining a smart contract wallet that can hold and transfer native currency and CIS-2 tokens.
26
+
Native currency/CIS-2 tokens can be deposited into the smart contract wallet by
27
27
specifying to which public key the deposit should be assigned.
28
28
29
29
The holder of the corresponding private key is the only entity that can authorize
30
30
to transfer tokens/currency in a self-custodial manner
31
31
from the public key balance (assigned in the smart contract) to some new accounts/smart contracts/public keys.
32
32
33
33
The holder of the corresponding private key does not have to submit transactions
34
-
on chain to transfer its native currency/cis2 token balance,
34
+
on chain to transfer its native currency/CIS-2 token balance,
35
35
but instead, it can generate a valid signature, identify a willing third
36
36
party to submit its signature on-chain (a service fee can be added to financially incentivize a third party to do so).
37
37
@@ -44,7 +44,7 @@ The three main actions in the smart contract that can be taken:
44
44
- *withdraw*: withdraws the balance out of the smart contract wallet to a native account or smart contract.
45
45
46
46
The goal of this standard is to simplify the account creation onboarding flow on Concordium
47
-
allowing for CIS5 smart contract wallets to be supported as first-class citizens in Concordium wallets and tooling.
47
+
allowing for CIS-5 smart contract wallets to be supported as first-class citizens in Concordium wallets and tooling.
48
48
49
49
Specification
50
50
=============
@@ -73,7 +73,7 @@ A token ID is serialized as 1 byte for the size (``n``) of the identifier, follo
73
73
74
74
Token IDs (as defined in the CIS-2 standard) can be as small as a single byte (by setting the first byte to the value 0)
75
75
or as big as 256 bytes.
76
-
The token ID in the CIS5 standard needs to be able to encode up to 256 bytes long Token IDs as a result.
76
+
The token ID in the CIS-5 standard needs to be able to encode up to 256 bytes long Token IDs as a result.
77
77
78
78
.. _CIS-5-TokenAmount:
79
79
@@ -82,7 +82,7 @@ A token ID is serialized as 1 byte for the size (``n``) of the identifier, follo
82
82
83
83
- The token amount SHALL be able to encode all possible tokenAmounts from the ``CIS-2 TokenAmount standard`` (:ref:`CIS-2-TokenAmount`). An amount of a token type is an unsigned integer up to 2^256 - 1.
84
84
85
-
It is serialized using the LEB128_ variable-length unsigned integer encoding, with the additional constraint of the total number of bytes of the encoding MUST not exceed 37 bytes::
85
+
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::
86
86
87
87
TokenAmount ::= (x: Byte) => x if x < 2^7
88
88
| (x: Byte) (m: TokenAmount) => (x - 2^7) + 2^7 * m if x >= 2^7
@@ -119,7 +119,7 @@ It is serialized as: First 8 bytes for the index (``index``) followed by 8 bytes
119
119
120
120
Is either an :ref:`CIS-5-AccountAddress` or a :ref:`CIS-5-ContractAddress`.
121
121
122
-
It is serialized as: First byte indicates whether it is an account address or a contract address.
122
+
It is serialized as: The first byte indicates whether it is an account address or a contract address.
123
123
In case the first byte is 0 then an :ref:`CIS-5-AccountAddress` (``address``) follows.
124
124
In case the first byte is 1 then a :ref:`CIS-5-ContractAddress` (``address``) follows::
125
125
@@ -201,9 +201,20 @@ It is serialized as 64 bytes::
201
201
202
202
Signing data contains metadata for the signature that is used to check whether the signed message is designated for the correct contract and entrypoint, and that it is not expired.
203
203
204
-
It is serialized as :ref:`CIS-5-ContractAddress` (``contract_address``), :ref:`CIS-5-EntrypointName` (``entrypoint``), :ref:`CIS-5-Nonce` (``nonce``), and :ref:`CIS-5-Timestamp` (``timestamp``)::
204
+
It is serialized as :ref:`CIS-5-ContractAddress` (``contract_address``), :ref:`CIS-5-EntrypointName` (``entrypoint``), :ref:`CIS-5-Nonce` (``nonce``), :ref:`CIS-5-Timestamp` (``timestamp``), :ref:`CIS-5-CCDAmount`/:ref:`CIS-5-TokenAmount` (``serviceFee``), and :ref:`CIS-5-Address` (``serviceFeeRecipient``)::
@@ -223,7 +234,7 @@ The ``NonceEvent`` is serialized as: First a byte with the value of 250, followe
223
234
``DepositNativeCurrencyEvent``
224
235
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
225
236
226
-
A ``DepositNativeCurrencyEvent`` SHALL be logged for every `depositNativeCurrency` function invoke.
237
+
A ``DepositNativeCurrencyEvent`` SHALL be logged for every ``depositNativeCurrency`` function invoke.
227
238
228
239
The ``DepositNativeCurrencyEvent`` 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``)::
229
240
@@ -232,18 +243,18 @@ The ``DepositNativeCurrencyEvent`` is serialized as: First a byte with the value
232
243
``DepositCis2TokensEvent``
233
244
^^^^^^^^^^^^^^^^^^^^^^^^^^
234
245
235
-
A ``DepositCis2TokensEvent`` SHALL be logged for every `depositCis2Tokens` function invoke.
246
+
A ``DepositCis2TokensEvent`` SHALL be logged for every ``depositCis2Tokens`` function invoke.
236
247
237
248
The ``DepositCis2TokensEvent`` is serialized as: First a byte with the value of 248, followed by the
A ``WithdrawNativeCurrencyEvent`` SHALL be logged for every `withdrawNativeCurrency` function invoke.
257
+
A ``WithdrawNativeCurrencyEvent`` SHALL be logged for every ``withdrawNativeCurrency`` function invoke.
247
258
248
259
The ``WithdrawNativeCurrencyEvent`` 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``)::
249
260
@@ -252,18 +263,18 @@ The ``WithdrawNativeCurrencyEvent`` is serialized as: First a byte with the valu
252
263
``WithdrawCis2TokensEvent``
253
264
^^^^^^^^^^^^^^^^^^^^^^^^^^^
254
265
255
-
A ``WithdrawCis2TokensEvent`` SHALL be logged for every `withdrawCis2Tokens` function invoke.
266
+
A ``WithdrawCis2TokensEvent`` SHALL be logged for every ``withdrawCis2Tokens`` function invoke.
256
267
257
268
The ``WithdrawCis2TokensEvent`` is serialized as: First a byte with the value of 246, followed by the
A ``InternalNativeCurrencyTransferEvent`` SHALL be logged for every `internalNativeCurrencyTransfer` function invoke.
277
+
A ``InternalNativeCurrencyTransferEvent`` SHALL be logged for every ``internalNativeCurrencyTransfer`` function invoke.
267
278
268
279
The ``InternalNativeCurrencyTransferEvent`` 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``)::
269
280
@@ -272,13 +283,13 @@ The ``InternalNativeCurrencyTransferEvent`` is serialized as: First a byte with
272
283
``InternalCis2TokensTransferEvent``
273
284
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274
285
275
-
A ``InternalCis2TokensTransferEvent`` SHALL be logged for every `internalCis2TokensTransfer` function invoke.
286
+
A ``InternalCis2TokensTransferEvent`` SHALL be logged for every ``internalCis2TokensTransfer`` function invoke.
276
287
277
288
The ``InternalCis2TokensTransferEvent`` is serialized as: First a byte with the value of 244, followed by the
:ref:`CIS-5-ContractAddress` (``contractAddress``), a :ref:`CIS-5-PublicKeyEd25519` (``from``), and the :ref:`CIS-5-PublicKeyEd25519` (``to``)::
290
+
:ref:`CIS-5-ContractAddress` (``cis2TokenContractAddress``), a :ref:`CIS-5-PublicKeyEd25519` (``from``), and the :ref:`CIS-5-PublicKeyEd25519` (``to``)::
@@ -337,7 +348,7 @@ of a CIS-2 token contract. The function deposits/assigns the send CIS-2 token am
337
348
The smart contract wallet is not required to check if the invoking contract is a CIS-2 token contract or has some reasonable receive hook logic implemented.
338
349
If no additional authorization is added to this function, similar caution should be applied as if you would directly interact with any CIS-2 token contract.
339
350
Only interact with a CIS-2 token contract or value its recorded token balance if you checked its smart
340
-
contract logic or reasonable social reputation are given to the project/CIS-2 token contract.
351
+
contract logic or reasonable social reputation is given to the project/CIS-2 token contract.
341
352
342
353
Parameter
343
354
~~~~~~~~~
@@ -360,7 +371,7 @@ Requirements
360
371
^^^^^^^^^^^^^^^^^^^^^^^^^^
361
372
362
373
The function executes a list of token withdrawals of CCDs (native currency) to native accounts and/or smart contracts out of the smart contract wallet.
363
-
When transferring CCD to a contract address, a ccd receive hook function MUST be triggered.
374
+
When transferring CCD to a contract address, a CCD receive hook function MUST be triggered.
364
375
365
376
Parameter
366
377
~~~~~~~~~
@@ -382,7 +393,7 @@ the receiving address :ref:`CIS-2-Receiver` (``to``), a :ref:`CIS-5-CCDAmount` (
382
393
CCD Receive hook parameter
383
394
~~~~~~~~~~~~~~~~~~~~~~~~~~
384
395
385
-
The parameter for the ccd receive hook function contains information about the transfer and some additional data bytes.
396
+
The parameter for the CCD receive hook function contains information about the transfer and some additional data bytes.
386
397
387
398
It is serialized as: a :ref:`CIS-5-CCDAmount` (``ccdAmount``), a :ref:`CIS-5-PublicKeyEd25519` (``from``), and some aditional data :ref:`CIS-2-AdditionalData` (``data``)::
388
399
@@ -396,14 +407,14 @@ Requirements
396
407
- The contract function MUST reject if any of the withdrawals fail to be executed.
397
408
- The function MUST emit a ``NonceEvent`` and a ``WithdrawNativeCurrencyEvent`` for every withdrawal.
398
409
- The function MUST reject if the signature verification fails for any withdrawal.
399
-
- The function MUST fail, if the CCD balance of the ``signer`` is insufficient to do the withdrawal for any withdrawal.
410
+
- The function MUST fail if the CCD balance of the ``signer`` is insufficient to do the withdrawal for any withdrawal.
400
411
- A function MUST non-strictly decrease the CCD balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail for any withdrawal.
401
412
- A withdrawal back to this contract into the ``depositNativeCurrency`` entrypoint MUST be executed as a normal withdrawal.
402
413
- A withdrawal of a CCD amount of zero MUST be executed as a normal withdrawal.
403
-
- A withdrawal of any amount of CCD to a contract address MUST call a ccd receive hook function on the receiving smart contract with a :ref:`ccd receive hook parameter<CIS-5-functions-transfer-ccd-receive-hook-parameter>`.
404
-
- The contract function MUST reject if the ccd receive hook function called on the contract receiving CCDs rejects for any withdrawal.
414
+
- A withdrawal of any amount of CCD to a contract address MUST call a CCD receive hook function on the receiving smart contract with a :ref:`ccd receive hook parameter<CIS-5-functions-transfer-ccd-receive-hook-parameter>`.
415
+
- The contract function MUST reject if the CCD receive hook function called on the contract receiving CCDs rejects for any withdrawal.
405
416
- The balance of a public key not owning any CCD amount SHOULD be treated as having a balance of zero.
406
-
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every withdrawal.
417
+
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every withdrawal if ``serviceFee!=0``.
407
418
408
419
.. warning::
409
420
@@ -442,12 +453,12 @@ Requirements
442
453
- The function MUST emit a ``NonceEvent`` and a ``WithdrawCis2TokensEvent`` for every withdrawal.
443
454
- The function MUST reject if the signature verification fails for any withdrawal.
444
455
- This function MUST call the ``transfer`` function on the CIS-2 token contract for every withdrawal.
445
-
- The function MUST fail, if the token balance of the ``signer`` is insufficient to do the withdrawal for any withdrawal.
456
+
- The function MUST fail if the token balance of the ``signer`` is insufficient to do the withdrawal for any withdrawal.
446
457
- A function MUST non-strictly decrease the token balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail for any withdrawal.
447
458
- A withdrawal back to this contract into the ``depositCis2Tokens`` entrypoint MUST be executed as a normal withdrawal.
448
459
- A withdrawal of a token amount of zero MUST be executed as a normal withdrawal.
449
460
- The balance of a public key not owning any tokens SHOULD be treated as having a balance of zero.
450
-
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every withdrawal.
461
+
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every withdrawal if ``serviceFee!=0``.
- The function MUST emit a ``NonceEvent`` and a ``InternalNativeCurrencyTransferEvent`` for every transfer.
477
488
- The function MUST reject if the signature verification fails for any transfer.
478
-
- The function MUST fail, if the CCD balance of the ``signer`` is insufficient to do the tranfser for any transfer.
489
+
- The function MUST fail if the CCD balance of the ``signer`` is insufficient to do the transfer for any transfer.
479
490
- A function MUST non-strictly decrease the CCD balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail for any transfer.
480
491
- A transfer of a CCD amount of zero MUST be executed as a normal transfer.
481
492
- The balance of a public key not owning any CCD amount SHOULD be treated as having a balance of zero.
482
-
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every transfer.
493
+
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every transfer if ``serviceFee!=0``.
483
494
484
495
.. _CIS-5-functions-internalCis2TokensTransfer:
485
496
@@ -508,11 +519,11 @@ Requirements
508
519
509
520
- The function MUST emit a ``NonceEvent`` and a ``InternalCis2TokensTransferEvent`` for every transfer.
510
521
- The function MUST reject if the signature verification fails for any of the transfers.
511
-
- The function MUST fail, if the token balance of the ``signer`` is insufficient to do the transfer for any transfer.
522
+
- The function MUST fail if the token balance of the ``signer`` is insufficient to do the transfer for any transfer.
512
523
- A function MUST non-strictly decrease the token balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail for any transfer.
513
524
- A transfer of a token amount of zero MUST be executed as a normal transfer.
514
525
- The balance of a public key not owning any tokens SHOULD be treated as having a balance of zero.
515
-
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every transfer.
526
+
- The function MUST transfer the ``serviceFee`` to the ``serviceFeeRecipient`` for every transfer if ``serviceFee!=0``.
516
527
517
528
.. _CIS-5-functions-balanceOfNativeCurrency:
518
529
@@ -524,7 +535,7 @@ The function queries the CCD balances of a list of public keys.
524
535
Parameter
525
536
~~~~~~~~~
526
537
527
-
The parameter consists of a list public keys.
538
+
The parameter consists of a list of public keys.
528
539
529
540
It is serialized as: 2 bytes for the number of queries (``n``) and then this number of queries (``queries``).
530
541
A query is serialized as a :ref:`CIS-5-PublicKeyEd25519` (``publicKey``)::
@@ -582,7 +593,7 @@ It is serialized as: 2 bytes for the number of token amounts (``n``) and then th
582
593
Requirements
583
594
~~~~~~~~~~~~
584
595
585
-
- The balance of an public key not owning any amount of a token type SHOULD be treated as having a balance of zero.
596
+
- The balance of a public key not owning any amount of a token type SHOULD be treated as having a balance of zero.
586
597
- The number of results in the response MUST correspond to the number of the queries in the parameter.
587
598
- The order of results in the response MUST correspond to the order of queries in the parameter.
588
599
- The contract function MUST NOT increase or decrease the CCD balance or token balance of any public key for any token type.
0 commit comments