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: protocol-contracts/confidential-wrapper-upgradeable/docs/README.md
+22-20Lines changed: 22 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,12 +31,12 @@ Zama provides a registry contract that maps ERC-20 tokens to their corresponding
31
31
**Important:** Prior to wrapping, the confidential wrapper contract must be approved by the `msg.sender` on the underlying token.
32
32
33
33
```solidity
34
-
wrapper.wrap(recipientAddress, amount);
34
+
wrapper.wrap(to, amount);
35
35
```
36
36
37
-
The wrapper will mint the corresponding confidential token to the `recipientAddress` and refund the excess tokens to the `msg.sender` (due to decimal conversion). Considerations:
37
+
The wrapper will mint the corresponding confidential token to the `to` address and refund the excess tokens to the `msg.sender` (due to decimal conversion). Considerations:
38
38
-`amount` must be a value using the same decimal precision as the underlying token.
39
-
-`recipientAddress` must not be the zero address.
39
+
-`to` must not be the zero address.
40
40
41
41
> ℹ️ **Low amount handling:** If the amount is less than the rate, the wrapping will succeed but the recipient will receive 0 confidential tokens and the excess tokens will be refunded to the `msg.sender`.
42
42
@@ -47,19 +47,21 @@ Unwrapping is a **two-step asynchronous process**: an `unwrap` must be first mad
47
47
48
48
#### 1) Unwrap request
49
49
50
+
> ⚠️ **Unsupported `from`:** Accounts with a zero balance that have never held tokens cannot be the `from` address in unwrap requests.
51
+
50
52
##### With input proof
51
53
52
-
> ℹ️ **Input proof:** To unwrap any amount of confidential tokens, the `fromAddress` must first create an encrypted input to generate an `encryptedAmount` (`externalEuint64`) along its `inputProof`. The amount to be encrypted must use the same decimal precision as the confidential wrapper. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/input).
54
+
> ℹ️ **Input proof:** To unwrap any amount of confidential tokens, the `from` address must first create an encrypted input to generate an `encryptedAmount` (`externalEuint64`) along its `inputProof`. The amount to be encrypted must use the same decimal precision as the confidential wrapper. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/input).
wrapper.unwrap(from, to, encryptedAmount, inputProof);
56
58
```
57
59
58
-
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `fromAddress`. For example, this can be the confidential balance of `fromAddress`.
60
+
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `from`. For example, this can be the confidential balance of `from`.
59
61
60
-
This requests an unwrap request of `encryptedAmount` confidential tokens from `fromAddress`. Considerations:
61
-
-`msg.sender` must be `fromAddress` or an approved operator for `fromAddress`.
62
-
-`fromAddress` mut not be the zero address.
62
+
This requests an unwrap request of `encryptedAmount` confidential tokens from `from`. Considerations:
63
+
-`msg.sender` must be `from` or an approved operator for `from`.
64
+
-`from` mut not be the zero address.
63
65
-`encryptedAmount` will be burned in the request.
64
66
-**NO** transfer of underlying tokens is made in this request.
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `fromAddress`. For example, this can be the confidential balance of `fromAddress`.
76
+
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `from`. For example, this can be the confidential balance of `from`.
On top of the above unwrap request considerations:
@@ -83,18 +85,20 @@ On top of the above unwrap request considerations:
83
85
84
86
#### 2) Finalize unwrap
85
87
86
-
> ℹ️ **Public decryption:** The encrypted burned amount emitted by the `UnwrapRequested` event must be publicly decrypted to get the `cleartextAmount` along its `decryptionProof`. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/decryption/public-decryption).
88
+
> ℹ️ **Public decryption:** The encrypted burned amount `burntAmount`emitted by the `UnwrapRequested` event must be publicly decrypted to get the `cleartextAmount` along its `decryptionProof`. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/decryption/public-decryption).
This finalizes the unwrap request by sending the corresponding amount of underlying tokens to the `recipientAddress` defined in the `unwrap` request.
94
+
This finalizes the unwrap request by sending the corresponding amount of underlying tokens to the `to` defined in the `unwrap` request.
93
95
94
96
### Transfer confidential tokens
95
97
96
98
> ℹ️ **Transfer with input proof:** Similarly to the unwrap process, transfers can be made with or without an input proof and the encrypted amount must be approved by the ACL for the `msg.sender`.
97
99
100
+
> ⚠️ **Unsupported `from`:** Accounts with a zero balance that have never held tokens cannot be the `from` address in confidential transfers.
101
+
98
102
#### Direct transfer
99
103
100
104
```solidity
@@ -112,7 +116,7 @@ token.confidentialTransferFrom(from, to, encryptedAmount);
112
116
```
113
117
114
118
Considerations:
115
-
-`msg.sender` must be `fromAddress` or an approved operator for `fromAddress`.
119
+
-`msg.sender` must be `from` or an approved operator for `from`.
116
120
117
121
#### Transfer with callback
118
122
@@ -135,7 +139,7 @@ token.confidentialTransferFromAndCall(from, to, encryptedAmount, callbackData);
135
139
```
136
140
137
141
Considerations:
138
-
-`msg.sender` must be `fromAddress` or an approved operator for `fromAddress`.
142
+
-`msg.sender` must be `from` or an approved operator for `from`.
The wrapper exposes a non-confidential view of the total supply, computed from the underlying ERC20 balance held by the wrapper contract. This value may be higher than `confidentialTotalSupply()` if tokens are sent directly to the wrapper outside of the wrapping process.
159
163
164
+
> ℹ️ **Total Value Shielded (TVS):** This view function is useful for getting a good approximation of the wrapper's Total Value Shielded (TVS).
@@ -267,13 +273,9 @@ Transfer functions with `euint64` (not `externalEuint64`) require the caller to
267
273
268
274
## Important Considerations
269
275
270
-
### Zero balance requirement
271
-
272
-
Accounts with a zero balance that have never held tokens cannot be the `from` address in transfers. This will revert with `ERC7984ZeroBalance`.
273
-
274
276
### Ciphertext uniqueness assumption
275
277
276
-
The unwrap mechanism stores requests in a mapping keyed by ciphertext. The current implementation assumes ciphertexts are unique. This holds in practice but be aware of this architectural decision as it is not true in the general case.
278
+
The unwrap mechanism stores requests in a mapping keyed by ciphertext and the current implementation assumes these ciphertexts are unique. This holds in this very specific case but be aware of this architectural decision as it is **NOT** true in the general case.
0 commit comments