Skip to content

M-Bln/ConfidentialERC1155

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConfidentialERC1155

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.

Table of Contents

Introduction

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.

Features

  • 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.

Getting Started

Prerequisites

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.

Installation

Install the dependencies:

pnpm install

Usage

Start fhevm

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

Compile the smart contract with Hardhat:

pnpm compile

TypeChain

Compile the smart contract and generate TypeChain bindings:

pnpm typechain

List Accounts

List all derived Ethereum addresses from the mnemonic in .env file:

pnpm task:accounts

Get Some Native Coins

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

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.

Test

Run the tests with Hardhat:

pnpm test

Lint Solidity

Lint the Solidity code:

pnpm lint:sol

Lint TypeScript

Lint the TypeScript code:

pnpm lint:ts

Report Gas

See the gas usage per unit test and average gas per method call:

REPORT_GAS=true pnpm test

Clean

Delete the smart contract artifacts, coverage reports, and the Hardhat cache:

pnpm clean

Mocked Mode

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.

License

This project is licensed under MIT.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published