This is an example app that uses Ethereum Name Service (ENS)'s evmgateway.
Check it out at https://evmgateway-starter.vercel.app/
The Passport NFT is as non-transferrable NFT on L1 (Goerli) that dynamically updates based on some of the owner's actions on L2 (OP Goerli). The NFT's tokenURI function performs two subsequent CCIP-Reads, and returns a svg string that encodes the read results.
What is evmgateway?
EVM Gateway is a CCIP-Read gateway that allows L1 smart contracts to fetch and verify state from L2s. Read more about it here.
- Hackers hacking on evmgateway
- Hackers interested in learning more about how an OP Stack chain works
- Hackers interested in learning more about how CCIP-Read works
Check out the contract here
L2TestCoinis deployed on OP GoerliL2TestNFTis deployed on OP GoerliL1PassportNFTis deployed on Goerli
tokenURIfunction on theL1PassportNFTcontract performs a CCIP-Read on theL2TestCoin'stotalSupplyandbalanceOfstorage slots for the current owner of the NFT.- When the CCIP-Read in step 1 succeeds,
L1PassportNFT'stokenURIFetchL2TestCoinBalanceCallbackis called tokenURIFetchL2TestCoinBalanceCallbackperforms another CCIP-Read onL2TestNFT's_balanceOf- When the CCIP-Read in step 3 succeeds,
L1PassportNFT'stokenURIFetchL2TestNFTBalanceCallbackis called tokenURIFetchL2TestNFTBalanceCallbacktakes the fetch results from the last 2 CCIP-Read calls, and then generates an svg string that displays the user'sL2TestCoinandL2TestNFTbalance.
The following are deployed versions of the op-gateway with delay = 0 and their corresponding op-verifier contracts
| chain | op-gateway service | op-verifier contract (on Goerli) |
|---|---|---|
| OP Goerli | https://op-goerli.op-gateway.transientdomain.xyz/{sender}/{data}.json | 0xe58448bfc2fa097953e800e0af0b0a5257ecc4b1 |
| Base Goerli | https://base-goerli.op-gateway.transientdomain.xyz/{sender}/{data}.json | 0x7e2f9c4a1467e8a41e1e8283ba3ba72e3d92f6b8 |
| contract | chain | address |
|---|---|---|
| L1PassportNFT | Goerli | 0x0e24f4af1d5cd7fac0a96649511a15439d7e0c04 |
| L2TestNFT | OP Goerli | 0x22299910e573ecd436f4987c75f093894904d107 |
| L2TestCoin | OP Goerli | 0x5a81f1f4d30f4153150848c31fabd0311946ed72 |
git clone https://github.com/ethereum-optimism/evmgateway-starter.gitcd evmgateway-starter-
Copy
.env.exampleto.env.cp .env.example .env
-
Edit your
.envto specify the environment variables.-
VITE_RPC_URL_GOERLI: HTTP RPC URL for Goerli -
VITE_RPC_URL_OP_GOERLI: HTTP RPC URL for OP-Goerli -
VITE_WALLETCONNECT_PROJECT_ID: WalletConnect v2 requires a project ID. You can obtain it from your WC dashboard: https://cloud.walletconnect.com/sign-in
-
-
Install the necessary node packages:
npm install
-
Start the frontend with
npm run devnpm run dev
-
Open localhost:5173 in your browser.
Using a testnet is recommended. You can use the existing deployment for op-verifier contract and the op-gateway service on Goerli (listed above).
For a local development environment, you will need to do the following
- run an Optimism Devnet
- run an op-gateway service against the devnet
- deploy op-verifier contract on the devnet that uses the op-gateway service
You will need to install Foundry to build your smart contracts.
-
Run the following command:
curl -L https://foundry.paradigm.xyz | bash -
Source your environment as requested by Foundry.
-
Run
foundryup.
-
Register for Etherscan. Add the api key to
ETHERSCAN_API_KEY_GOERLIin your.envfile -
Register for Etherscan on Optimism. This account is different from your normal Etherscan account. Add this api key to
ETHERSCAN_API_KEY_OP_GOERLIin your.envfile
-
Deploy the
L2TestCoincontract on OP Goerlinpm run deploy:l2-test-coin
-
Deploy the
L2TestNFTcontract on OP Goerlinpm run deploy:l2-test-nft
-
Update the
VITE_L2TESTNFT_CONTRACT_ADDRESS_OP_GOERLIandVITE_L2TESTCOIN_CONTRACT_ADDRESS_OP_GOERLIwith the addresses of the newly deployed contracts. This will be used as inputs for theL1PassportNFTcontract -
Deploy the
L1PassportNFTcontract on Goerlinpm run deploy:l1-passport-nft