3. Deploy a smart contract using Hardhat
Since the SDK of nervos is different from the SDK of ETH's web3.js and ether.js, the default hardhat cannot be used directly, you need to add polyjuice-provider

1. Open the Nervos Hardhat template

Deploy (modified for compatibility) Ethereum smart contracts on Nervos' Godwoken Polyjuice and interact with them using the Ethereum blockchain.

2. Steps

1. Open npm-Hardhat from the command line

2. Generate Hardhat environment variables under different networks

Please read the Nervos IDE environment configuration document first to make sure you know how to connect to the corresponding network and receive test tokens
When metamask successfully connects to the local network and obtains a certain amount of test coins, click Tools on the right, select the desired network (devnet, testnet, mainnet) -- click the network rollup configuration -- click the hardhat that environment variable, you can have hardhat Generate a .env file that needs to fill in the key in the .config folder. (.env.dev corresponds to devnet, .env corresponds to testnet, and .env.main corresponds to mainnet)
Taking .env.dev (corresponding to devnet) as an example, the player needs to replace your private key with the private key of the deployer, private key A, private key B, and the multi-signature wallet for the contract with the corresponding multi-signature wallet. The private key (at least 1) is required to sign the contract, ctrl + s to save.
DEPLOYER_PRIVATE_KEY= your private key
RPC_URL=https://sandbox1df79ec5d055godwoken-kicker-dind-8024.gateway.chainide.com
NETWORK_SUFFIX=gwk-devnet
SIGNER_PRIVATE_KEYS=Private key A, Private key B, multi-signature wallet for contracts
ROLLUP_TYPE_HASH=0x828b8a63f97e539ddc79e42fa62dac858c7a9da222d61fc80f0d61b44b5af5d4
ETH_ACCOUNT_LOCK_CODE_HASH=0xf96d799a3c90ac8e153ddadd1747c6067d119a594f7f1c4b1fffe9db0f304335
POLYJUICE_CONTRACT_CODE_HASH=0x6677005599a98f86f003946eba01a21b54ed1f13a09f36b5e8bbcf7586b96b41
CREATOR_ACCOUNT_ID=3
GODWOKEN_API_URL=https://sandbox1df79ec5d055godwoken-kicker-dind-6101.gateway.chainide.com

3. Upgradeable Contracts

Smart Contracts: Box.sol, BoxV2.sol

3.1 Ready to work

Generate hardhat environment variables
Install dependencies and compile contracts
yarn install
yarn compile

3.2 Deploy

# testnet
yarn ts-node ./scripts/box-proxy.ts​
# devnet
ENV_PATH=./.env.dev yarn ts-node ./scripts/box-proxy.ts

3.3 Compatibility Modification Instructions

Fully compatible, no modification required

4. Multisignature Wallet

This example implements a simple multi-signature wallet. For more details, see the wallet simple contract code.
Smart contracts: WalletSimple.sol, MintableToeknFixedPatams.sol

4.1 Ready to work

Install dependencies (if have not been installed before)
yarn install
yarn compile

4.2 Deploy

# testnet
yarn ts-node ./scripts/multi-sign-wallet.ts
# devnet
ENV_PATH=./.env.dev yarn ts-node ./scripts/multi-sign-wallet.ts

4.3 Compatibility Modification Instructions

See WalletSimple.diff for Polyjuice compatibility fixes.
Since ecrecover Ethereum addresses instead of Godwoken addresses, it's pretty much useless or polyjuice. If your contract needs to recover Godwoken addresses, use polyRecover (a special version of ecrecover in polyjuice). For more information about Godwoken address VS Ethereum Address, click here

5. Mulitcall

This example demonstrates how to dynamically call one or more contract methods in a contract.
Smart contract: Multicall.sol

5.1 Ready to work

Install dependencies and compile the contract (if have not been done before)
yarn install
yarn compile

5.2 Deploy

# testnet
yarn ts-node ./scripts/create2.ts
​# devnet
ENV_PATH=./.env.dev yarn ts-node ./scripts/create2.ts

5.3 Compatibility Modification Instructions

An additional method (ConvertETHAddrToGodwokenAddr in Create2.sol) is required to convert the contract address for on-chain computation.

6. CREATE2

This example shows how the generated address is calculated (both on-chain and off-chain). CREATE2

6.1 Ready to work

Install dependencies and compile the contract (if have not been done before)
yarn install
yarn compile

6.2 Deploy

# testnet
yarn ts-node ./scripts/create2.ts
​# devnet
ENV_PATH=./.env.dev yarn ts-node ./scripts/create2.ts

6.3 Compatibility Modification Instructions

An additional method (ConvertETHAddrToGodwokenAddr in Create2.sol) is required to convert the contract address for on-chain computation.

7. Curve StableSwap

This example contains a 3-pool infrastructure for Curver's stable coin transactions
Smart Contracts: StableSwap3Pool.vy, CurveTokenV3.vy, MintableToken.sol, Faucet.sol

7.1 Ready to work

Install the dependencies and compile the contract (if have not been done before)
yarn install
yarn compile

7.2 Deploy

# testnet
yarn ts-node ./scripts/stable-swap-3-pool.ts​
# devnet
ENV_PATH=./.env.dev yarn ts-node ./scripts/stable-swap-3-pool.ts

7.3 Compatibility Modification Instructions

Fully compatible, no modification required.