Skip to content

ChiHaoLu/stablecoin-zkSync

Repository files navigation

Minimal Circle's Stablecoin Smart Contracts on zkSync Era

Modified from Circle's Stablecoin repo.

DON'T USE THIS REPO IN YOUR PRODUCT!!! IT'S JUST FOR DEVELOPMENT ON ZKSYNC ERA TESTNET!!!

Requirements

Usage

Build

$ forge install
$ forge build

Compile

$ forge build --zksync

Test

$ forge test --zksync

Deployment

  1. Create a copy of the file .env.example, and name it .env. Fill in appropriate values in the .env file. This file must not be checked into the repository.
$ cp .env.example .env
  1. Create a blacklist.remote.json file and populate it with a list of addresses to be blacklisted. This file must not be checked into the repository.
$ echo "[]" > blacklist.remote.json
  1. Simulate a deployment by running the following command
$ forge script script/deploy/deploy-fiat-token.s.sol:DeployFiatToken -vv --gas-estimate-multiplier 110  --rpc-url testnet --zksync
  1. Validate that all transactions to be broadcasted are filled in with the correct values
  2. Deploy the contracts by running the following command
$ forge script script/deploy/deploy-fiat-token.s.sol -vv --gas-estimate-multiplier 110 --rpc-url testnet --broadcast --zksync
  1. Verify the contracts on an Etherscan flavored block explorer by running the following command. Ensure that <ETHERSCAN_KEY> is filled.
$ forge script script/deploy/deploy-fiat-token.s.sol -vv --gas-estimate-multiplier 110 --rpc-url testnet --verify --resume --etherscan-api-key <ETHERSCAN_KEY> --zksync

Problem: LLVM IR generator definition pass error

I have published an issue here

I found USDC (Proxy contract) deploys with this similar code successfully on zkSync Era, but I still can't figure out how to solve this problem.

  • Reproduce:
$ forge build --zksync
>
[⠒] Compiling...
No files changed, compilation skipped

Error:
Failed to compile with zksolc: Compilation failed with "Contract `contracts/v2/FiatTokenV2.sol:FiatTokenV2` compiling error: 

The contract `contracts/v2/FiatTokenV2.sol:FiatTokenV2` LLVM IR generator definition pass error: 

Library `contracts/util/SignatureChecker.sol:SignatureChecker` not found in the project

The contract `contracts/v2/FiatTokenV2.sol:FiatTokenV2` LLVM IR generator definition pass error: 

Library `contracts/util/SignatureChecker.sol:SignatureChecker` not found in the project\n\n\nStack backtrace:
    0: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    1: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    2: __mh_execute_header
    3: __mh_execute_header
    4: __mh_execute_header
    5: __mh_execute_header
    6: __mh_execute_header
    7: __mh_execute_header
    8: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    9: __mh_execute_header
    10: __mh_execute_header
    11: __mh_execute_header
    12: __mh_execute_header
    13: __mh_execute_header
    14: __mh_execute_header
    15: __mh_execute_header
    16: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    17: __mh_execute_header
    18: __mh_execute_header
    19: __mh_execute_header
    20: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    21: __pthread_deallocate\n". 

Using compiler: "/Users/chihaolu/.zksync/zksolc-macosx-arm64-v1.4.0", with args "/Users/chihaolu/Desktop/project/stablecoin-zkSync/contracts/v2/FiatTokenV2.sol" ["--standard-json", "--solc", "/Users/chihaolu/.svm/0.6.12/solc-0.6.12"]
  • Solution: ❌
  • Some related issues:
    • type(*).runtimeCode, zkSync do not support it: link
    • EXTCODECOPY: link
    • EXTCODECOPY: link
    • solidity-coverage: link