Git Product home page Git Product logo

web3-scaffold's Introduction

web3 scaffold

Quickly get up and running on web3

This scaffold is set up as a monorepo using the incredibly fast pnpm, with packages for each part of the project. All of these packages use a common Typescript foundation with linting and autoformatting and is best used with VSCode. It assumes you'll be deploying to an EVM-compatible blockchain.

Packages

app

This is the frontend of your project. It's built on Next.js using Tailwind CSS. Data is read from the smart contract via a subgraph (below) using urql and autogenerated Typescript definitions with GraphQL Code Generator.

contracts

This is where your smart contracts live. They're written in Solidity using Foundry (forge & cast) to compile, test, and deploy. Types are generated with TypeChain.

subgraph

This is the read-only backend for your project and where you can offload a lot of the heavy lifting that would traditionally be done through an eth RPC node. It's written in AssemblyScript and deployed to The Graph.

Deploying

Vercel

Vercel supports monorepos and pnpm out-of-the-box, but you'll need to set the "Root Directory" to packages/app either during the Vercel project setup or afterwards in the project settings.

Misc install notes

If the submodules in forge are not working, you can remove the directories and reinstall directly with forge:

$ forge install chiru-labs/ERC721A --no-commit

$ forge install foundry-rs/forge-std --no-commit

$ forge install OpenZeppelin/openzeppelin-contracts --no-commit

If you install any other submodules, remember to re-run the mappings:

$ forge remappings > remappings.txt 

If you need to install jq for Mac (used to in the contracts/deploy.sh script), run:

$ brew install jq

web3-scaffold's People

Contributors

davisshaver avatar holic avatar jamiew avatar therightchoyce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

web3-scaffold's Issues

Had troubles deploying new contracts

I followed the doc you wrote. But when I tried to change the minting price in ExampleNFT.sol from 0.1 to 0.01 ether, I ran the http://deploy.sh it only gives me "Using goerli contract address: 0xe584409f2ba1ade9895485d90587fd46baa3c0d8" over and over again, even if I tried to write a new contract. I had set up the local env.

(Thanks to the reply from @TheRightChoyce: I need to delete the packages/contracts/deploys/goerli/ExampleNFT.json and run the ./deploy.sh in packages/contracts to deploy a new contract before trying to redeploy the new contract, otherwise the shell script will exit and just print the existing contact info. Now I can deploy new contracts. Thanks to him)

Improvements

  • Run through setup process and write a setup guide
  • Move common eslint stuff for TS to root or subpackage
  • Compile TS for imported packages (just contracts for now I think?) and rip out the webpack TS build step. This should make it easier to replace Next.js with something else.
  • Consider moving to Prettier -> eslint, rather than eslint -> Prettier. This will make it easier to autoformat things that eslint doesn't support but prettier does (CSS, SVG, HTML, etc.)
  • Make sure packages put files in the right place (e.g. contracts ABI -> subgraph ABI) or can generate their own from dependency/import
  • Consider removing/ignoring contracts artifacts and typechain-types

consider making subgraph opt-in

not sure this will be always needed in the default setup and the codegen is kinda clunky, esp if it breaks/is pointed at the wrong thing, and this may become more apparent once the hosted subgraph is taken offline

Add Setup Wizard

Something similar to powerlevel9k where you use a shell script to set up your bash prompt.

I think there are a few config options that would be cool to have in particular, and set up your scaffold in the way you prefer through running the script. It starts as something very vanilla if the script is never run.

This might defeat the purpose of the opinionated scaffold, but gives more flexibility for everyone to use IMO.

Init

Set your package names in all the package.json files

Package Manager

  • pnpm (default)
  • yarn + lerna?
  • npm + lerna

Wallet Connect Options

  • RainbowKit/Wagmi (default)
  • useWallet/web3modal

GraphQL Options

  • urql (default)
  • swr + graphql-request

Editor Options
(multi-select)

  • prettier (default)
  • eslint (default)

CSS Options

  • Tailwind (default)
  • Vanilla
  • etc

Also I'm happy to start on this after I get a few things done

rename?

It was web3-dapp-scaffold, then web3-app-scaffold (because I didn't feel right calling it a decentralized app), and now web3-scaffold.

I'm not a massive fan of the "scaffold" word, feels a little obscure, borrowed from Ruby(?), and probably hurts word of mouth long term?

Maybe create-web3-app?

Quick start for README

Super sorry for the beginners question, but is there a quick start for installing all parts of the repo?
Something like
Install packages

pnpm install

Installing and Deploying contracts

cd packages/contracts
yarn compile

Install and deploy subgraph

cd packages/subgraph
yarn build
yarn deploy:goerli

Install and deploy frontend

cd packages/app
npm run dev

Uncaught Exception in Next.js API Route

I encountered an uncaught exception in my Next.js API route. The error message I received was:

// 500 Internal Server Error

Uncaught Exception 	{"errorType":"Error","errorMessage":"Unexpected server response: 400","stack":["Error: Unexpected server response: 400","    at ClientRequest.<anonymous> (/var/task/node_modules/.pnpm/ws@7.4.6/node_modules/ws/lib/websocket.js:604:7)","    at ClientRequest.emit (node:events:513:28)","    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)","    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)","    at TLSSocket.socketOnData (node:_http_client:534:22)","    at TLSSocket.emit (node:events:513:28)","    at addChunk (node:internal/streams/readable:315:12)","    at readableAddChunk (node:internal/streams/readable:289:9)","    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)","    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)"]}
Unknown application error occurred
Runtime.Unknown

I've tried adding additional error handling code to my API route, but I'm still experiencing this issue: route handler

I implemented the same routes in a new nextjs app and it work perfectly: new route handler

Add CSP support

With the recent Solana dep chain exploit, thinking it’s important to have some sane security defaults. Not sure CSP will help in the context of extension-based wallets but it certainly can’t hurt to minimize attack surface area.

see also #44

hide lint warnings in CI?

These seem to be noisy in PRs. But maybe we ought to just fix all of them so that warnings in PRs are for realsies.

Build errors when implementing nextjs api

Getting a build error when I push next js api implementation:

ELIFECYCLE  Command failed with exit code 1.

16:59:19.472 | Error: Command "pnpm run build" exited with 1

Does this project need extra configs for api to build?

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.