Skip to content

Commit 3bf90c2

Browse files
committed
docs: build instructions
1 parent 0fadf51 commit 3bf90c2

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

README.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,42 @@ This is an implementation of a [SNIP-20](https://github.com/SecretFoundation/SNI
55
> **Note:**
66
> 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.
77
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+
## <a name="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+
## <a name="instantiation"></a>Token instantiation
30+
831
At the time of token creation you may configure:
32+
933
* Public Total Supply: If you enable this, the token's total supply will be displayed whenever a TokenInfo query is performed. DEFAULT: false
1034
* Enable Deposit: If you enable this, you will be able to convert from SCRT to the token.* DEFAULT: false
1135
* 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
1236
* 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
1337
* 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
1439

1540

1641
\*: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.
1742

18-
## Usage examples:
43+
## <a name="usage"></a>Usage examples:
1944

2045
To create a new token:
2146

@@ -60,21 +85,21 @@ To view the deposit/redeem exchange rate:
6085
```secretcli q compute query <contract-address> '{"exchange_rate": {}}'```
6186

6287

63-
## Troubleshooting
88+
## <a name="troubleshooting"></a>Troubleshooting
6489

6590
All transactions are encrypted, so if you want to see the error returned by a failed transaction, you need to use the command
6691

6792
`secretcli q compute tx <TX_HASH>`
6893

69-
## Privacy Enhancements
94+
## <a name="privacy"></a>Privacy Enhancements
7095

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.
7398
- 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.
7499

75-
## SNIP-52: Private Push Notifications
100+
## <a name="push"></a>Private Push Notifications
76101

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.
78103

79104
Direct channels:
80105
- `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:
86111
- `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.
87112

88113

89-
## Security Features
114+
## <a name="push"></a>Security Features
90115

91116
- 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.
117+
118+

0 commit comments

Comments
 (0)