ConfidentialERC1155 is a smart contract that extends the standard ERC1155 to include confidential data associated with each token ID. This allows users to mint tokens with encrypted data that can only be accessed by the token holders, utilizing fully homomorphic encryption (FHE) tools provided by the fhevm.
ConfidentialERC1155 is designed to manage confidential data on the blockchain, enabling secure and private data handling in decentralized applications. This project particularly focuses on use cases where the confidential data can serve as encryption keys for files stored in decentralized storage systems like IPFS.
- Extended ERC1155: Inherits the standard ERC1155 functionalities.
- Confidential Data: Associates encrypted confidential data with each token type.
- MintWithConfidentialData: New mint function that includes encrypted data.
- reMint: Allows re-minting of existing tokens by the owner with the same encrypted data.
Before running any command, create a .env
file and set a BIP-39 compatible mnemonic as an environment variable. Follow
the example in .env.example
. If you don't have a mnemonic, use this website to
generate one.
Install the dependencies:
pnpm install
Start a local fhevm docker container that includes everything needed to deploy FHE encrypted smart contracts:
# In one terminal, keep it open to view node logs
pnpm fhevm:start
To stop the container:
pnpm fhevm:stop
Compile the smart contract with Hardhat:
pnpm compile
Compile the smart contract and generate TypeChain bindings:
pnpm typechain
List all derived Ethereum addresses from the mnemonic in .env
file:
pnpm task:accounts
Get coins for the first 5 addresses derived from the mnemonic in .env
file:
pnpm fhevm:faucet
To get the first derived address from mnemonic
pnpm task:getEthereumAddress
Deploy the ConfidentialERC1155 to the local network:
pnpm deploy:contracts
Error: cannot get the transaction for EncryptedERC20's previous deployment
Delete the local folder in deployments:
rm -r deployments/local/
Info: by default, the local network is used
You can change the network in the hardhat config file.
Run the tests with Hardhat:
pnpm test
Lint the Solidity code:
pnpm lint:sol
Lint the TypeScript code:
pnpm lint:ts
See the gas usage per unit test and average gas per method call:
REPORT_GAS=true pnpm test
Delete the smart contract artifacts, coverage reports, and the Hardhat cache:
pnpm clean
The mocked mode allows faster testing and the ability to analyze coverage of the tests. In this mocked version, encrypted types are not really encrypted, and the tests are run on the original version of the EVM, on a local Hardhat network instance.
pnpm test:mock
To analyze the coverage of the tests (in mocked mode):
pnpm coverage:mock
Then open the file coverage/index.html
.
This project is licensed under MIT.