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: content/confidential-contracts/token.mdx
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: ERC7984
2
+
title: ERC-7984
3
3
---
4
4
5
-
[`ERC7984`](/confidential-contracts/api/token#ERC7984) is a standard fungible token implementation that is similar to ERC-20, but built from the ground up with confidentiality in mind. All balance and transfer amounts are represented as ciphertext handles, ensuring that no data is leaked to the public.
5
+
[ERC-7984](/confidential-contracts/api/token#ERC7984) is a standard fungible token implementation that is similar to ERC-20, but built from the ground up with confidentiality in mind. All balance and transfer amounts are represented as ciphertext handles, ensuring that no data is leaked to the public.
6
6
7
7
While the standard is built with inspiration from ERC-20, it is not ERC-20 compliant--the standard takes learning from all tokens built over the past 10 years (ERC-20, ERC-721, ERC-1155, ERC-6909 etc) and provides an interface for maximal functionality.
8
8
@@ -20,7 +20,7 @@ Select the appropriate transfer function and generate a ciphertext using [fhevm-
20
20
21
21
### Operator
22
22
23
-
An operator is an address that has the ability to move tokens on behalf of another address by calling `transferFrom`. If Bob is an operator for Alice, Bob can move any amount of Alice’s tokens at any point in time. Operators are set using an expiration timestamp--this can be thought of as a limited duration infinite approval for an `ERC20`. Below is an example of setting Bob as an operator for Alice for 24 hours.
23
+
An operator is an address that has the ability to move tokens on behalf of another address by calling `transferFrom`. If Bob is an operator for Alice, Bob can move any amount of Alice’s tokens at any point in time. Operators are set using an expiration timestamp--this can be thought of as a limited duration infinite approval for an ERC-20. Below is an example of setting Bob as an operator for Alice for 24 hours.
24
24
25
25
```typescript
26
26
const alice:Wallet;
@@ -55,9 +55,9 @@ Here is an example of a contract for a confidential fungible token with a privil
55
55
56
56
Swapping is one of the most primitive use-cases for fungible tokens. Below are examples for swapping between confidential and non-confidential tokens.
57
57
58
-
#### Swap `ERC20` to `ERC7984`
58
+
#### Swap ERC-20 to ERC-7984
59
59
60
-
Swapping from a non-confidential `ERC20` to a confidential `ERC7984` is simple and actually done within the `ERC7984ERC20Wrapper`. See the excerpt from the `wrap` function below.
60
+
Swapping from a non-confidential ERC-20 to a confidential ERC-7984 is simple and actually done within the `ERC7984ERC20Wrapper`. See the excerpt from the `wrap` function below.
61
61
62
62
```solidity
63
63
function wrap(address to, uint256 amount) public virtual {
@@ -69,11 +69,11 @@ function wrap(address to, uint256 amount) public virtual {
69
69
}
70
70
```
71
71
72
-
The `ERC20` token is simply transferred in, which would revert on failure. We then transfer out the correct amount of the `ERC7984` using the internal `_mint` function, which is guaranteed to succeed.
72
+
The ERC-20 token is simply transferred in, which would revert on failure. We then transfer out the correct amount of the ERC-7984 using the internal `_mint` function, which is guaranteed to succeed.
73
73
74
-
#### Swap `ERC7984` to `ERC7984`
74
+
#### Swap ERC-7984 to ERC-7984
75
75
76
-
Swapping from a confidential `ERC7984` to another confidential `ERC7984` is a bit more complex although quite simple given the usage of the `FHE` library. For the sake of the example, we will swap from `fromToken` to `toToken` with a 1:1 exchange rate.
76
+
Swapping from a confidential ERC-7984 to another confidential ERC-7984 is a bit more complex although quite simple given the usage of the `FHE` library. For the sake of the example, we will swap from `fromToken` to `toToken` with a 1:1 exchange rate.
77
77
78
78
```solidity
79
79
function swapConfidentialForConfidential(
@@ -102,7 +102,7 @@ The steps are as follows:
102
102
4. Allow the `toToken` to access `amountTransferred`
103
103
5. Transfer `amountTransferred` to `msg.sender`
104
104
105
-
#### Swap `ERC7984` to `ERC20`
105
+
#### Swap ERC-7984 to ERC-20
106
106
107
107
Swapping from a confidential token to a non-confidential token is the most complex since the decrypted data must be accessed to accurately complete the request. Decryption in our example will be done off-chain and relayed back using Zama’s Gateway. Below is an example of a contract doing a 1:1 swap from a confidential token to an ERC20 token.
0 commit comments