Home

Awesome

test workflow

About

The fhe-erc3643 package is an almost full port of the entire Tokeny Solutions TREX package using FHE to encrypt token amounts accross the entire TREX platform. The TFHE lib is deployed on the ERC20 token itself as well as all the ModularCompliance architecture.

It is essentially a single Hardhat project with an integrated CLI (via the hardhat task system) that allows the user to deploy a full FHE-TREX token on a local Zama node.

Development Roadmap

Install & Test

Install

npm install

Test on hardhat network

npm run test

Test on local fhevm node (very slow)

npm run test:fhevm

Start/stop/restart a local fhevm node

# starts a new local node (if not already running)
npm run start
# stops the running local node
npm run stop
# restart a running local node
npm run restart

How to use the FHE token manually

Setup a TREX token (slow)

The new token address is displayed at the end of the deployment process.

npx hardhat --network fhevm trex setup --mint 1000 --unpause

Inspect the lastest deployed TREX token

npx hardhat --network fhevm token show

Wallet and token aliases

Instead of using addresses you can execute CLI commands using wallet aliases. The available of aliases are listed in the table below. Token address is optional, if not provided, the CLI will use the latest valid deployed token. You can also use the symbol/name of the token instead of its address

# use token address
npx hardhat --network fhevm token mint --token 0x3Aa5ebB10DC797CAC828524e59A333d0A371443c --agent "token-agent" --user alice --amount 10n
# use token symbol
npx hardhat --network fhevm token mint --token MEG --agent "token-agent" --user alice --amount 10n
# resolve token address automatically
npx hardhat --network fhevm token mint --agent "token-agent" --user alice --amount 10n

Interacting with the TREX token

Use the token commands to interact with the token

npx hardhat --network fhevm token mint --token <token address> --agent "token-agent" --user alice --amount 10n

Example interacting with the ExchangeMonthlyLimitsModule compliance module

The following interaction is fully FHE compliant (from start to finish). (See ./test/scripts/fhevm/ExchangeMonthlyLimits.sh)

# setup the TREX environment
npx hardhat --network fhevm trex setup --mint 1000 --unpause
# register bob'id as an exchanger 
npx hardhat --network fhevm token exchangemonthly:add-id --token 0x47DA632524c03ED15D293e34256D28BD0d38c7a4 --owner token-owner --user bob
# specify bob's limits
npx hardhat --network fhevm token exchangemonthly:set-exchange-limit --token 0x47DA632524c03ED15D293e34256D28BD0d38c7a4 --owner token-owner --exchange-id bob --limit 100
# Alice transfers 10 tokens to bob
npx hardhat --network fhevm token transfer --token 0x47DA632524c03ED15D293e34256D28BD0d38c7a4 --wallet alice --to bob --amount 10
# Display bob's remaining credits
npx hardhat --network fhevm token exchangemonthly:get-monthly-counter --token 0x47DA632524c03ED15D293e34256D28BD0d38c7a4 --exchange-id bob --investor-id alice --decrypt

Example running the DvA contract in full FHE mode

A full running script is available at ./test/scripts/fhevm/DVA.sh

# For a complete list of DvA commands:
npx hardhat transfer-manager --help

The 🚧 hardhat-fhevm 🚧 npm package

fhe-erc3643 uses the hardhat-fhevm hardhat plugin, which offers a set of hardhat tasks to develop solidity contracts on top of Zama's FHEVM. It supports both the mock and local node modes. The hardhat-fhevm hardhat plugin is currently in alpha testing. Future versions should be fully re-architectured to better support external nodes like Anvil, Hardhat node and Zama dev-node.

The test wallets and roles

NameWallet indexWallet aliasesRoleNote
🚀 admin0adminowner of the TREXFactory
🏫 foo-university1foo-universityclaim issuerstored in the token's Identity registry
🏛️ bar-government2bar-governmentclaim issuerstored in the token's Identity registry
🏦 super-bank3super-bank, token-ownertoken owner
👨‍🚀 token-agent4token-agenttoken agent
👩 alice5alicetoken holderhas an identity stored in the token's Identity registry
👱🏼‍♂️ bob6bobtoken holderhas an identity stored in the token's Identity registry
👱🏼‍♂️ charlie7charlietoken holderhas an identity stored in the token's Identity registry
👱🏼‍♂️ david8davidtoken holderhas an identity stored in the token's Identity registry
👩 eve9evetoken holderhas an identity stored in the token's Identity registry
🦈 MEGALODON__TREX tokenthe deployed TREX token

Limitations: