-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8155d7b
commit 764b531
Showing
3 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Get Started on ZAMA Devnet | ||
|
||
## Devnet information | ||
|
||
Our devnet is up and running. | ||
|
||
<!-- markdown-link-check-disable --> | ||
|
||
| Fields | Value | | ||
| ------------------ | --------------------------------------------- | | ||
| New RPC URL | https://devnet.zama.ai | | ||
| Chain ID | 9000 | | ||
| Currency symbol | ZAMA | | ||
| Gateway URL | https://gateway.devnet.zama.ai | | ||
| Faucet URL | https://faucet.zama.ai | | ||
| Block explorer URL | https://explorer.devnet.zama.ai (coming soon) | | ||
|
||
<!-- markdown-link-check-enable --> | ||
|
||
## Configuring MetaMask | ||
|
||
<!-- markdown-link-check-disable --> | ||
|
||
To configure the [MetaMask](<(https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC)>) for Zama Devnet, follow the steps: | ||
|
||
<!-- markdown-link-check-enable --> | ||
|
||
1. From the homepage of your wallet, click on the network selector in the top left, and then on 'Add network' | ||
|
||
<figure><img src="../.gitbook/assets/metamask_add_network.gif" alt="How to add network from popup" width="300"><figcaption> | ||
</figcaption></figure> | ||
|
||
2. MetaMask will open in a new tab in fullscreen mode. From here, find and the 'Add network manually' button at the bottom of the network list. | ||
<figure><img src="../.gitbook/assets/metamask_add_network2.webp" alt="How to add network"><figcaption> | ||
</figcaption></figure> | ||
<!-- markdown-link-check-disable --> | ||
|
||
3. Add these information to access to blockchain | ||
|
||
{% tabs %} | ||
{% tab title="Zama devnet" %} | ||
|
||
| Fields | Value | | ||
| ----------------------------- | ------------------------------- | | ||
| Network Name | Zama Network | | ||
| New RPC URL | https://devnet.zama.ai | | ||
| Chain ID | 9000 | | ||
| Currency symbol | ZAMA | | ||
| Block explorer URL (Optional) | https://explorer.devnet.zama.ai | | ||
|
||
{% endtab %} | ||
{% tab title="Local devnet" %} | ||
|
||
| Fields | Value | | ||
| ----------------------------- | ---------------------- | | ||
| Network Name | Zama Local | | ||
| New RPC URL | http://localhost:8545/ | | ||
| Chain ID | 9000 | | ||
| Currency symbol | ZAMA | | ||
| Block explorer URL (Optional) | | | ||
|
||
{% endtab %} | ||
{% endtabs %} | ||
|
||
<!-- markdown-link-check-enable --> | ||
|
||
4. Choose the Zama Devnet | ||
<figure><img src="../.gitbook/assets/metamask_select_network.png" alt="How to select correct network on Metamask" width="300"><figcaption> | ||
</figcaption></figure> | ||
|
||
## Using Zama Faucet | ||
|
||
{% hint style="warning" %} | ||
**Devnet down** Our devnet is currently offline but will be up soon! In the meantime, develop your contracts using a local instance. | ||
{% endhint %} | ||
|
||
You can get 10 Zama token on [https://faucet.zama.ai/](https://faucet.zama.ai/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# What is fhEVM | ||
|
||
<figure><img src="../.gitbook/assets/doc_header_fhevm.png" alt=""><figcaption></figcaption></figure> | ||
|
||
## Introduction | ||
|
||
There used to be a dilemma in blockchain: keep your application and user data on-chain, allowing everyone to see it, or keep it privately off-chain and lose contract composability. | ||
|
||
**fhEVM** is a technology that enables confidential smart contracts on the EVM using Fully Homomorphic Encryption (FHE). | ||
|
||
Thanks to a breakthrough in FHE, Zama’s fhEVM makes it possible to run confidential smart contracts on encrypted data, guaranteeing both confidentiality and composability with: | ||
|
||
- **End-to-end encryption of transactions and state**: Data included in transactions is encrypted and never visible to anyone. | ||
- **Composability and data availability on-chain**: States are updated while remaining encrypted at all times. | ||
- **No impact on existing dapps and state**: Encrypted state co-exists alongside public one, and doesn't impact existing dapps. | ||
|
||
## Main features | ||
|
||
- **Solidity integration**: fhEVM contracts are simple solidity contracts that are built using traditional solidity toolchains. | ||
- **Simple developer experience**: Developers can use the euint data types to mark which part of their contracts should be private. | ||
- **Programmable privacy**: All the logic for access control of encrypted states is defined by developers in their smart contracts. | ||
- **High precision encrypted integers** : Up to 256 bits of precision for integers | ||
-Full range of Operators : All typical operators are available: +, -, \*, /, <, >, ==, … | ||
- **Encrypted `if-else` conditionals**: Check conditions on encrypted states | ||
- **On-chain PRNG**: Generate secure randomness without using oracles | ||
- **Configurable decryption**: Threshold, centralized or KMS decryption | ||
- **Unbounded compute depth**: Unlimited consecutive FHE operations | ||
|
||
## Use cases | ||
|
||
- **Tokenization**: Swap tokens and RWAs on-chain without others seeing the amounts. | ||
- **Blind auctions**: Bid on items without revealing the amount or the winner. | ||
- **On-chain games**: Keep moves, selections, cards, or items hidden until ready to reveal. | ||
- **Confidential voting**: Prevents bribery and blackmailing by keeping votes private. | ||
- **Encrypted DIDs**: Store identities on-chain and generate attestations without ZK. | ||
- **Private transfers**: Keep balances and amounts private, without using mixers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# Gas Estimation in fhEVM | ||
|
||
This guide helps you understand and estimate gas costs for Fully Homomorphic Encryption (FHE) operations in your smart contracts. | ||
|
||
## Overview | ||
|
||
When working with encrypted data in fhEVM, operations consume more gas compared to regular smart contract operations. This is because FHE operations require complex mathematical computations to maintain data privacy and security. | ||
|
||
Below you'll find detailed gas cost estimates for common FHE operations across different encrypted data types. Use these as a reference when designing and optimizing your confidential smart contracts. | ||
|
||
> **Note**: Gas costs are approximate and may vary slightly based on network conditions and contract complexity. | ||
## ebool | ||
|
||
| Function name | Gas | | ||
| ---------------- | ------ | | ||
| `and`/`or`/`xor` | 26,000 | | ||
| `not` | 30,000 | | ||
|
||
## euint4 | ||
|
||
| function name | Gas | | ||
| ---------------------- | ------- | | ||
| `add`/`sub` | 65,000 | | ||
| `add`/`sub` (scalar) | 65,000 | | ||
| `mul` | 150,000 | | ||
| `mul` (scalar) | 88,000 | | ||
| `div` (scalar) | 139,000 | | ||
| `rem` (scalar) | 286,000 | | ||
| `and`/`or`/`xor` | 32,000 | | ||
| `shr`/`shl` | 116,000 | | ||
| `shr`/`shl` (scalar) | 35,000 | | ||
| `rotr`/`rotl` | 116,000 | | ||
| `rotr`/`rotl` (scalar) | 35,000 | | ||
| `eq`/`ne` | 51,000 | | ||
| `ge`/`gt`/`le`/`lt` | 70,000 | | ||
| `min`/`max` | 121,000 | | ||
| `min`/`max` (scalar) | 121,000 | | ||
| `neg` | 60,000 | | ||
| `not` | 33,000 | | ||
| `select` | 45,000 | | ||
|
||
## euint8 | ||
|
||
| Function name | Gas | | ||
| ---------------------- | ------- | | ||
| `add`/`sub` | 94,000 | | ||
| `add`/`sub` (scalar) | 94,000 | | ||
| `mul` | 197,000 | | ||
| `mul` (scalar) | 159,000 | | ||
| `div` (scalar) | 238,000 | | ||
| `rem` (scalar) | 460,000 | | ||
| `and`/`or`/`xor` | 34,000 | | ||
| `shr`/`shl` | 133,000 | | ||
| `shr`/`shl` (scalar) | 35,000 | | ||
| `rotr`/`rotl` | 133,000 | | ||
| `rotr`/`rotl` (scalar) | 35,000 | | ||
| `eq`/`ne` | 53,000 | | ||
| `ge`/`gt`/`le`/`lt` | 82,000 | | ||
| `min`/`max` | 128,000 | | ||
| `min`/`max` (scalar) | 128,000 | | ||
| `neg` | 95,000 | | ||
| `not` | 34,000 | | ||
| `select` | 47,000 | | ||
| `randEuint8()` | 100,000 | | ||
|
||
## euint16 | ||
|
||
| function name | euint16 | | ||
| ---------------------- | ------- | | ||
| `add`/`sub` | 133,000 | | ||
| `add`/`sub` (scalar) | 133,000 | | ||
| `mul` | 262,000 | | ||
| `mul` (scalar) | 208,000 | | ||
| `div` (scalar) | 314,000 | | ||
| `rem` (scalar) | 622,000 | | ||
| `and`/`or`/`xor` | 34,000 | | ||
| `shr`/`shl` | 153,000 | | ||
| `shr`/`shl` (scalar) | 35,000 | | ||
| `rotr`/`rotl` | 153,000 | | ||
| `rotr`/`rotl` (scalar) | 35,000 | | ||
| `eq`/`ne` | 54,000 | | ||
| `ge`/`gt`/`le`/`lt` | 105,000 | | ||
| `min`/`max` | 153,000 | | ||
| `min`/`max` (scalar) | 150,000 | | ||
| `neg` | 131,000 | | ||
| `not` | 35,000 | | ||
| `select` | 47,000 | | ||
| `randEuint16()` | 100,000 | | ||
|
||
## euint32 | ||
|
||
| Function name | Gas fee | | ||
| ---------------------- | ------- | | ||
| `add`/`sub` | 162,000 | | ||
| `add`/`sub` (scalar) | 162,000 | | ||
| `mul` | 359,000 | | ||
| `mul` (scalar) | 264,000 | | ||
| `div` (scalar) | 398,000 | | ||
| `rem` (scalar) | 805,000 | | ||
| `and`/`or`/`xor` | 35,000 | | ||
| `shr`/`shl` | 183,000 | | ||
| `shr`/`shl` (scalar) | 35,000 | | ||
| `rotr`/`rotl` | 183,000 | | ||
| `rotr`/`rotl` (scalar) | 35,000 | | ||
| `eq`/`ne` | 82,000 | | ||
| `ge`/`gt`/`le`/`lt` | 128,000 | | ||
| `min`/`max` | 183,000 | | ||
| `min`/`max` (scalar) | 164,000 | | ||
| `neg` | 160,000 | | ||
| `not` | 36,000 | | ||
| `select` | 50,000 | | ||
| `randEuint32()` | 100,000 | | ||
|
||
## euint64 | ||
|
||
| Function name | Gas fee | | ||
| ---------------------- | --------- | | ||
| `add`/`sub` | 188,000 | | ||
| `add`/`sub` (scalar) | 188,000 | | ||
| `mul` | 641,000 | | ||
| `mul` (scalar) | 356,000 | | ||
| `div` (scalar) | 584,000 | | ||
| `rem` (scalar) | 1,095,000 | | ||
| `and`/`or`/`xor` | 38,000 | | ||
| `shr`/`shl` | 227,000 | | ||
| `shr`/`shl` (scalar) | 38,000 | | ||
| `rotr`/`rotl` | 227,000 | | ||
| `rotr`/`rotl` (scalar) | 38,000 | | ||
| `eq`/`ne` | 86,000 | | ||
| `ge`/`gt`/`le`/`lt` | 156,000 | | ||
| `min`/`max` | 210,000 | | ||
| `min`/`max` (scalar) | 192,000 | | ||
| `neg` | 199,000 | | ||
| `not` | 37,000 | | ||
| `select` | 53,000 | | ||
| `randEuint64()` | 100,000 | | ||
|
||
## eaddress | ||
|
||
| Function name | Gas fee | | ||
| ------------- | ------- | | ||
| `eq`/`ne` | 90,000 | | ||
|
||
## Gas limit | ||
|
||
The current devnet has a gas limit of **10,000,000**. Here's what you need to know: | ||
|
||
- If you send a transaction that exceeds this limit: | ||
- The transaction will fail to execute | ||
- Your wallet will be unable to emit new transactions | ||
- You'll need to send a new transaction with the same nonce but correct gas limit | ||
|
||
### Fixing Failed Transactions in MetaMask | ||
|
||
To resolve a failed transaction due to gas limits: | ||
|
||
1. Open MetaMask and go to Settings | ||
2. Navigate to Advanced Settings | ||
3. Enable "Customize transaction nonce" | ||
4. When resending the transaction: | ||
- Use the same nonce as the failed transaction | ||
- Set an appropriate gas limit under 10M | ||
- Adjust other parameters as needed | ||
|
||
This allows you to "replace" the failed transaction with a valid one using the correct gas parameters. |