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
L2TestCoin
is deployed on OP GoerliL2TestNFT
is deployed on OP GoerliL1PassportNFT
is deployed on Goerli
tokenURI
function on theL1PassportNFT
contract performs a CCIP-Read on theL2TestCoin
'stotalSupply
andbalanceOf
storage slots for the current owner of the NFT.- When the CCIP-Read in step 1 succeeds,
L1PassportNFT
'stokenURIFetchL2TestCoinBalanceCallback
is called tokenURIFetchL2TestCoinBalanceCallback
performs another CCIP-Read onL2TestNFT
's_balanceOf
- When the CCIP-Read in step 3 succeeds,
L1PassportNFT
'stokenURIFetchL2TestNFTBalanceCallback
is called tokenURIFetchL2TestNFTBalanceCallback
takes the fetch results from the last 2 CCIP-Read calls, and then generates an svg string that displays the user'sL2TestCoin
andL2TestNFT
balance.
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.git
cd evmgateway-starter
-
Copy
.env.example
to.env
.cp .env.example .env
-
Edit your
.env
to 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 dev
npm 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_GOERLI
in your.env
file -
Register for Etherscan on Optimism. This account is different from your normal Etherscan account. Add this api key to
ETHERSCAN_API_KEY_OP_GOERLI
in your.env
file
-
Deploy the
L2TestCoin
contract on OP Goerlinpm run deploy:l2-test-coin
-
Deploy the
L2TestNFT
contract on OP Goerlinpm run deploy:l2-test-nft
-
Update the
VITE_L2TESTNFT_CONTRACT_ADDRESS_OP_GOERLI
andVITE_L2TESTCOIN_CONTRACT_ADDRESS_OP_GOERLI
with the addresses of the newly deployed contracts. This will be used as inputs for theL1PassportNFT
contract -
Deploy the
L1PassportNFT
contract on Goerlinpm run deploy:l1-passport-nft