3 files, 1 repo
A few weeks ago, I started looking at Optimisms Layer 2. What I needed was a simple local demo that runs tests on contracts. A simple repo a dev could clone and understand how Optimism functions. Many of the repos didn’t work out of the box, were moving targets, or had different ways to use hardhat. No singlular repo had what I wanted, so I created this while tinkering. Tests are mostly from here [Optimism Repo] and it has additional tests to feed your curiosity. Hopefully, someone finds it a useful introduction. Enjoy.
Simple Optimism Tutorial
Demo Instructions
terminal #1 (optimism integration)
git clone https://github.com/ethereum-optimism/optimism-integration.git
cd optimism-integration
./up.shterminal #2 (optimism test)
git clone https://github.com/brucedotio/optimism-tutorial.git
cd optimism-tutorial
yarn install && yarn test
Test Output
3 Goals
Test Token functions the same while targeting a specific layer/chainId
Test sending messages across chains l1->l2, l2->l1 works with both layers running
Verify transfer, gateway, and deposit works with both layers running
3 Test Files
test\erc20.spec.js
test\crosschain\SendMessage.spec.js
test\crosschain\l1tol2Integrations.spec.js
Remaining Issues
- There should be a more elegant method of including from @eth-optimism/contracts. Adding contracts to ./contracts/optimism should not be necessary.
- An Intermittent crash from the optimism-integration message-relayer container causes the “L2 → L1 message send” test in ./test/crosschain/SendMessage.spec.js to fail. Restarting the container generally fixes the issue. Other times it is necessary to restart the entire docker composed stack.
Other Sources:
https://azfuller20.medium.com/optimism-scaffold-eth-draft-b76d3e6849e8
https://github.com/austintgriffith/scaffold-eth/tree/local-optimism
https://github.com/ethereum-optimism/optimism-integration
https://github.com/ethereum-optimism/integration-tests
https://github.com/Synthetixio/synthetix/tree/develop/test/optimism