Skip to content

Latest commit

 

History

History
82 lines (58 loc) · 2.05 KB

README.md

File metadata and controls

82 lines (58 loc) · 2.05 KB

Taiko protocol

This package contains rollup contracts on both L1 and L2, along with other assisting code. Taiko L2's chain ID is 167.

Compile

To compile smart contracts, run:

pnpm compile

If you run into Error: Unknown version provided, you should upgrade your foundry installation by running curl -L https://foundry.paradigm.xyz | bash.

Deploy

Deploy TaikoL1 on hardhat network:

pnpm deploy:hardhat

Test

Run test cases on hardhat network:

pnpm test

Run test cases that require a running go-ethereum node:

pnpm test:integration

Generate L2 genesis JSON's alloc field

Start by creating a config.json, for example:

{
  // Owner address of the pre-deployed L2 contracts.
  "contractOwner": "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39",
  // Chain ID of the Taiko L2 network.
  "chainId": 167,
  // Account address and pre-mint ETH amount as key-value pairs.
  "seedAccounts": [
    { "0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39": 1024 },
    { "0x79fcdef22feed20eddacbb2587640e45491b757f": 1024 }
  ],
  // L2 EIP-1559 baseFee calculation related fields.
  "param1559": {
    "yscale": "358298803609133338137582400989",
    "xscale": "1488514844",
    "gasIssuedPerSecond": "12500000",
    "gasExcess": "45450000000"
  },
  // Option to pre-deploy an ERC-20 token.
  "predeployERC20": true
}

Next, run the generation script:

pnpm compile && pnpm generate:genesis config.json

The script will output two JSON files under ./deployments:

  • l2_genesis_alloc.json: the alloc field which will be used in L2 genesis JSON file
  • l2_genesis_storage_layout.json: the storage layout of those pre-deployed contracts

Using Foundry

This project also integrates with Foundry for building and testing contracts.

  • To compile using foundry: forge build or pnpm compile
  • To run foundry tests: forge test --gas-report -vvv or pnpm test:foundry

Note that compiling with foundry uses dependencies inside the lib dir (instead of node_modules).