The Encrypted ERC-20 (eERC) standard enables secure and confidential token transfers on Avalanche blockchains. Leveraging zk-SNARKs and partially homomorphic encryption, the eERC protocol offers robust privacy without requiring protocol-level modifications or off-chain intermediaries.
AvaCloud API documentation can be found here.
- Confidential Transactions: User balances and transaction amounts remain completely hidden, ensuring financial privacy.
- Large Integers: Efficiently handles token amounts up to 128 bits (2^128), accommodating substantial financial transactions.
- Client-Side Operations: Users retain control, performing encryption, decryption, and zk-proof generation directly on their own devices.
- Fully On-chain Nature: Operates entirely on-chain without the need for relayers or off-chain actors.
- Built-in Compliance: Supports external auditors, ensuring regulatory compliance.
- contracts Smart contract source files
- scripts Utility and deployment scripts
- src Encryption utilities for TypeScript
- tests Test scripts and helpers
- zk Gnark-based implementations of zero-knowledge proof components
You need following dependencies for setup:
NodeJS >= v16.x
Golang >= 1.23.x
-
Clone the repo
git clone https://github.com/ava-labs/EncryptedERC.git
-
Install NPM packages
npm install
Note: This command will run a bash script to compile gnark's circuits, if this does not work: In zk directory run the following command to build manually:
make
or
go build -o ./build/encryptedERC ./cmd/
-
Compile the contracts
npx hardhat compile
The Standalone version lets users create entirely new private ERC-20 tokens with built-in privacy, supporting confidential minting and burning.
- Start the local node
npx hardhat node
- Deploy the contract
npx hardhat run scripts/deploy-standalone.ts --network localhost
Refer to the scripts/deploy-standalone.ts script for deployment examples.
The Converter version adds privacy features to existing ERC-20 tokens, enabling users to convert standard ERC-20 tokens to private ones and switch between public and private states through deposit and withdrawal functions.
- Start the local node
npx hardhat node
- Deploy the contract
npx hardhat run scripts/deploy-converter.ts --network localhost
Refer to the scripts/deploy-converter.ts script for deployment examples.
Contract tests:
npx hardhat coverage
·················································································································
| Solidity and Network Configuration │
····························|·················|···············|·················|································
| Solidity: 0.8.27 · Optim: true · Runs: 200 · viaIR: false · Block: 30,000,000 gas │
····························|·················|···············|·················|································
| Network: AVALANCHE · L1: 1 gwei · · 21.91 usd/avax │
····························|·················|···············|·················|················|···············
| Contracts / Methods · Min · Max · Avg · # calls · usd (avg) │
····························|·················|···············|·················|················|···············
| EncryptedERC · │
····························|·················|···············|·················|················|···············
| deposit · 71,842 · 841,926 · 565,079 · 16 · 0.01 │
····························|·················|···············|·················|················|···············
| privateBurn · 872,327 · 1,209,788 · 1,010,477 · 4 · 0.02 │
····························|·················|···············|·················|················|···············
| privateMint · 704,167 · 752,463 · 713,839 · 10 · 0.02 │
····························|·················|···············|·················|················|···············
| setAuditorPublicKey · - · - · 103,800 · 4 · - │
····························|·················|···············|·················|················|···············
| setTokenBlacklist · - · - · 46,443 · 1 · - │
····························|·················|···············|·················|················|···············
| transfer · 929,453 · 929,477 · 929,469 · 6 · 0.02 │
····························|·················|···············|·················|················|···············
| withdraw · 764,964 · 820,100 · 786,662 · 6 · 0.02 │
····························|·················|···············|·················|················|···············
| register · 315,948 · 316,008 · 315,985 · 20 · 0.01 │
····························|·················|···············|·················|················|···············
Tested on M3 Pro CPU:
Operation | Proving Time |
---|---|
Registration | 71 ms |
Private Mint | 359 ms |
Private Burn | 360 ms |
Private Transfer | 606 ms |