Giter VIP home page Giter VIP logo

optimism-starter's Introduction

EthDenver

Optimism

Optimism ETH Denver hackathon starterkit.


This is a Optimism + wagmi + Foundry + + Rainbowkit + Vite project originally bootstrapped with create-wagmi built with ❤️ for Eth Denver hackers

Who is this for

Getting Started

Run npm run dev in your terminal, and then open localhost:5173 in your browser.

Once the webpage has loaded, changes made to files inside the src/ directory (e.g. src/App.tsx) will automatically update the webpage.

See below for general usage instructions or FAQ for answers to general questions such as

  • where to get goerli eth
  • how to deploy to vercel/fleek

Generating ABIs & React Hooks

This project comes with @wagmi/cli built-in, which means you can generate wagmi-compatible (type safe) ABIs & React Hooks straight from the command line.

To generate ABIs & Hooks, follow the steps below.

Install Foundry

First, you will need to install Foundry in order to build your smart contracts. This can be done by running the following command:

curl -L https://foundry.paradigm.xyz | bash

Generate code

To generate ABIs & React Hooks from your Foundry project (in ./contracts), you can run:

npm run wagmi

This will use the wagmi config (wagmi.config.ts) to generate a src/generated.ts file which will include your ABIs & Hooks that you can start using in your project.

Here is an example of where Hooks from the generated file is being used.

Deploying Contracts

To deploy your contracts to a network, you can use Foundry's Forge – a command-line tool to tests, build, and deploy your smart contracts.

You can read a more in-depth guide on using Forge to deploy a smart contract here, but we have included a simple script in the package.json to get you started.

Below are the steps to deploying a smart contract to Ethereum Mainnet using Forge:

Install Foundry

Make sure you have Foundry installed & set up.

See the above instructions.

Set up environment

You will first need to set up your .env to tell Forge where to deploy your contract.

Go ahead and open up your .env file, and enter the following env vars:

  • ETHERSCAN_API_KEY: Your Etherscan API Key.
  • FORGE_RPC_URL: The RPC URL of the network to deploy to.
  • FORGE_PRIVATE_KEY: The private key of the wallet you want to deploy from.

note Optimism goerli requires signing up for an etherscan key on optimism goerli etherscan rather than mainnet etherscan

Deploy contract

You can now deploy your contract!

npm run deploy

Developing with Anvil (Goerli Fork)

Let's combine the above sections and use Anvil alongside our development environment to use our contracts (./contracts) against an Optimism fork.

Install Foundry

Make sure you have Foundry installed & set up.

See the above instructions.

Start dev server

Run the command:

npm run dev:foundry

This will:

  • Start a Next.js dev server,
  • Start the @wagmi/cli in watch mode to listen to changes in our contracts, and instantly generate code,
  • Start an Anvil instance (Mainnet Fork) on an RPC URL.

Deploy our contract to Anvil

Now that we have an Anvil instance up and running, let's deploy our smart contract to the Anvil network:

pnpm run deploy:anvil

Start developing

Now that your contract has been deployed to Anvil, you can start playing around with your contract straight from the web interface!

Head to localhost:5173 in your browser, connect your wallet, and try increment the counter on the Foundry chain.

Tip: If you import an Anvil private key into your browser wallet (MetaMask, Coinbase Wallet, etc) – you will have 10,000 ETH to play with 😎. The private key is found in the terminal under "Private Keys" when you start up an Anvil instance with npm run dev:foundry.

ATST

To interact with the attestation station this library uses the minimal @eth-optimism/atst package currently in beta as well as it's accompioning cli. Feel free to open up issues for ideas of improvements for atst. We are also happy to give you ideas of how you could build an even better version of ATST or make it better for your hack!

ATST indexers

TODO document what you can use for backends for atst

Alternatives

Looking to use burner wallets? Prefer hardhat? Prefer NEXT.js? Check out these amazing alternatives:

  • create wagmi cli - A flexible cli with many templates (this starterkit was started from vite-react-cli-foundry)
  • scaffold-eth - The new 2nd version of a popular NEXT.js based starter including hardhat, burner wallets, great documentation, and an active telegram for support
  • Awesome wagmi - Has other alternative examples
  • Create Eth App - Uses a wagmi alternative called useDapp that is used at OP Labs

Learn more

To learn more about Optimism Vite, Foundry, Rainbow kit or wagmi, check out the following resources:

optimism-starter's People

Contributors

roninjin10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.