Code Monkey home page Code Monkey logo

next-web3-boilerplate's Introduction

⚠️ Notice

This template is no longer under active maintenance, it's out-of-date with the state of the ethereum ecosystem. Some reccomendations for replacing this would be to use the Next.js + TypeScript + ConnectKit example from Family, using wagmi directly or web3modal.

Deploy with Vercel

This is a default Next.js project bootstrapped with create-next-app, customized as the default boilerplate for new Web3 projects.

Features

  • Separate packages from ethers.js for improved tree-shaking, often only ethers Contracts
  • Hooks-first approach to fetching and caching data from Contracts and memoization for performance with SWR
  • web3-react for ease of connecting to Web3 providers with a solid API
  • Auto-generates types for the contract ABIs in the /contracts folder via TypeChain

Auto Contract Type Generation

Note: After adding in your new contract ABIs (in JSON format) to the /contracts folder, run yarn compile-contract-types to generate the types.

You can import these types when declaring a new Contract hook. The types generated show the function params and return types of your functions, among other helpful types.

import MY_CONTRACT_ABI from "../contracts/MY_CONTRACT.json";
import type { MY_CONTRACT } from "../contracts/types";
import useContract from "./useContract";

export default function useMyContract() {
  return useContract<MY_CONTRACT>(CONTRACT_ADDRESS, MY_CONTRACT_ABI);
}

Previous Art

Getting Started

First, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

next-web3-boilerplate's People

Contributors

dependabot[bot] avatar mirshko 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

next-web3-boilerplate's Issues

useEagerConnect does not work on SSR

Hi!

I'm not sure if I'm completely missing the point here, but it seems that useEagerConnect() does not currently work on Next.js or any prerendered site since the window.ethereumproperty cannot be accessed server-side.

I've tried both creating my own project from scratch and also cloned this one to confirm it.

I'm also getting the following console output:

MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193

I'm quite new to SSR so I might be doing some stuff the wrong way.

error thrown points at isLoading on Account.js

Hey my friend! First of all thank you for providing this useful boilerplate!!! :D

I just have an issue, whenever I render the component I get this error in the console:

Screen Shot 2021-04-02 at 1 51 34 AM

Which indicates there's a problem with this line of code:

Screen Shot 2021-04-02 at 1 53 12 AM

So.. What do you suggest me to do? For now the only way to get rid of the error is to remove the prop isLoading. Is this a bad solution? Would love to hear some feedback.

Thanks again and have an amazing day!!

On yarn dev: Warning: useLayoutEffect does nothing on the server

Thanks for the awesome project! Found this warning when running yarn dev

yarn run v1.22.10
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
event - compiled successfully
event - build page: /
wait  - compiling...
event - compiled successfully
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.

Triggered by this line in Account.tsx

  useLayoutEffect(() => {
    onboarding.current = new MetaMaskOnboarding();
  }, [])

Support Redux (or any state management) Out-of-the-Box?

Hey there,
Thanks for the repo. Was wondering if you plan to support State Management out-of-the-box, it seems important for Metamask to be always connected throughout DApps like the one I'm creating. The could be a yarn command which builds it. Or a cookiecutter template.

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.