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: README.md
+35-9Lines changed: 35 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,17 +5,42 @@ This is an implementation of a [SNIP-20](https://github.com/SecretFoundation/SNI
5
5
> **Note:**
6
6
> The master branch contains new features not covered by officially-released SNIPs and may be subject to change. When releasing a token on mainnet, we recommend you start with a [tagged release](https://github.com/scrtlabs/snip20-reference-impl/tags) to ensure compatibility with SNIP standards.
7
7
8
+
*[Building](#building)
9
+
*[Token instantiation](#instantiation)
10
+
*[Usage examples](#usage)
11
+
*[Troubleshooting](#troubleshooting)
12
+
*[Privacy Enchancements](#privacy)
13
+
*[Private Push Notifications](#push)
14
+
*[Security Features](#security)
15
+
16
+
## <aname="building"></a>Building
17
+
18
+
With the introduction delayed write buffers (DWBs) and bitwise trie of bucketed entries (BTBEs) (see [Privacy Enchancements](#privacy) below) developers must configure the code prior to building the contract WASM.
19
+
20
+
The crate `build.rs` file reads two environment values `DWB_CAPACITY` and `BTBE_CAPACITY`, which correspond to the size of the DWB and bucket size for the BTBE, respectively. If the environemnt variables are not set, then they will both be set to `64`. The higher these values, the greater the anonymity set but also the higher the gas cost for transactions. See [here](https://hackmd.io/twnenQuoSp61hK_YWJo9oA) for a more technical description of how DWBs and BTBEs work.
21
+
22
+
A second consideration is how many bytes to use to store user balances in the DWB and BTBE. The default value used in the master branch code is 8 bytes (u64 size). Using only 8 bytes to store balance saves gas when writing the balances in the DWB and BTBE. 8 bytes translates to a maximum token balance in base denomination for a single account equal to approximately 18 quadrillion. For most tokens with 6 decimals, this is more than sufficient. However, some tokens such as secret wrapped ERC-20 tokens can have 18 decimals and this upper bound might not be enough. In that case, you will want to store balances with 16 bytes (u128 size).
23
+
24
+
There are two tagged releases that we recommend using, depending on the requirements of your token:
25
+
26
+
- Tokens with 64-bit balances, e.g. sSCRT: [Release-64-bit-balance]() TODO
27
+
- Tokens with 128-bit balances, e.g. wrapped ERC-20 : [Release-128-bit-balance]() TODO
28
+
29
+
## <aname="instantiation"></a>Token instantiation
30
+
8
31
At the time of token creation you may configure:
32
+
9
33
* Public Total Supply: If you enable this, the token's total supply will be displayed whenever a TokenInfo query is performed. DEFAULT: false
10
34
* Enable Deposit: If you enable this, you will be able to convert from SCRT to the token.* DEFAULT: false
11
35
* Enable Redeem: If you enable this, you will be able to redeem your token for SCRT.* It should be noted that if you have redeem enabled, but deposit disabled, all redeem attempts will fail unless someone has sent SCRT to the token contract. DEFAULT: false
12
36
* Enable Mint: If you enable this, any address in the list of minters will be able to mint new tokens. The admin address is the default minter, but can use the set/add/remove_minters functions to change the list of approved minting addresses. DEFAULT: false
13
37
* Enable Burn: If you enable this, addresses will be able to burn tokens. DEFAULT: false
38
+
* Can Modify Denoms: If you enable this, an admin can modify supported denoms. DEFAULT: false
14
39
15
40
16
41
\*:The conversion rate will be 1 uscrt for 1 minimum denomination of the token. This means that if your token has 6 decimal places, it will convert 1:1 with SCRT. If your token has 10 decimal places, it will have an exchange rate of 10000 SCRT for 1 token. If your token has 3 decimal places, it will have an exchange rate of 1000 tokens for 1 SCRT. You can use the exchange_rate query to view the exchange rate for the token. The query response will display either how many tokens are worth 1 SCRT, or how many SCRT are worth 1 token. That is, the response lists the symbol of the coin that has less value (either SCRT or the token), and the number of those coins that are worth 1 of the other.
17
42
18
-
## Usage examples:
43
+
## <aname="usage"></a>Usage examples:
19
44
20
45
To create a new token:
21
46
@@ -60,21 +85,21 @@ To view the deposit/redeem exchange rate:
All transactions are encrypted, so if you want to see the error returned by a failed transaction, you need to use the command
66
91
67
92
`secretcli q compute tx <TX_HASH>`
68
93
69
-
## Privacy Enhancements
94
+
## <aname="privacy"></a>Privacy Enhancements
70
95
71
-
- All transfers/sends (including batch and *_from) use the delayed write buffer (dwb) to address "spicy printf" storage access pattern attacks.
72
-
- Additionally, a bitwise trie of bucketed entries (dwb) creates dynamic anonymity sets for senders/owners, whose balance must be checked when transferring/sending. It also enhances privacy for recipients.
96
+
- All transfers/sends (including batch and *_from) use the delayed write buffer (DWB) to address "spicy printf" storage access pattern attacks.
97
+
- Additionally, a bitwise trie of bucketed entries (BTBE) creates dynamic anonymity sets for senders/owners, whose balance must be checked when transferring/sending. It also enhances privacy for recipients.
73
98
- When querying for Transaction History, each event's `id` field returned in responses are deterministically obfuscated by `ChaChaRng(XorBytes(ChaChaRng(actual_event_id), internal_secret)) >> (64 - 53)` for better privacy. Without this, an attacker could deduce the number of events that took place between two transactions.
74
99
75
-
## SNIP-52: Private Push Notifications
100
+
## <aname="push"></a>Private Push Notifications
76
101
77
-
This contract publishes encrypted messages to the event log which carry data intended to notify recipients of actions that affect them, such as token transfer and allowances.
102
+
This contract implements SNIP-52. It publishes encrypted messages to the event log which carry data intended to notify recipients of actions that affect them, such as token transfer and allowances.
78
103
79
104
Direct channels:
80
105
-`recvd` -- emitted to a recipient when their account receives funds via one of `transfer`, `send`, `transfer_from`, or `send_from`. The notification data includes the amount, the sender, and the memo length.
@@ -86,7 +111,8 @@ Group channels:
86
111
-`multispent` -- emitted to a group of spenders (up to 16) when a `batch_transfer_from`, or `batch_send_from` has been executed. Each spender will receive a packet of data containing the amount that was spent, the last 8 bytes of the recipient's address, and some additional metadata.
87
112
88
113
89
-
## Security Features
114
+
## <aname="push"></a>Security Features
90
115
91
116
- Transfers to the contract itself will be rejected to prevent accidental loss of funds.
92
-
- The migration allows for a one-time processing of refunding any previous transfers made to the contract itself.
0 commit comments