Skip to content

Commit 14da80e

Browse files
committed
Initial commit with 🏗️ Scaffold-ETH 2 @ 1.0.1
0 parents  commit 14da80e

File tree

146 files changed

+26829
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+26829
-0
lines changed

.cursor/rules/scaffold-eth.mdc

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
7+
This codebase contains Scaffold-ETH 2 (SE-2), everything you need to build dApps on Ethereum. Its tech stack is NextJS, RainbowKit, Wagmi and Typescript. Supports Hardhat and Foundry.
8+
9+
It's a yarn monorepo that contains following packages:
10+
11+
- HARDHAT (`packages/hardhat`): The solidity framework to write, test and deploy EVM Smart Contracts.
12+
- NextJS (`packages/nextjs`): The UI framework extended with utilities to make interacting with Smart Contracts easy (using Next.js App Router, not Pages Router).
13+
14+
15+
The usual dev flow is:
16+
17+
- Start SE-2 locally:
18+
- `yarn chain`: Starts a local blockchain network
19+
- `yarn deploy`: Deploys SE-2 default contract
20+
- `yarn start`: Starts the frontend
21+
- Write a Smart Contract (modify the deployment script in `packages/hardhat/deploy` if needed)
22+
- Deploy it locally (`yarn deploy`)
23+
- Go to the `http://locahost:3000/debug` page to interact with your contract with a nice UI
24+
- Iterate until you get the functionality you want in your contract
25+
- Write tests for the contract in `packages/hardhat/test`
26+
- Create your custom UI using all the SE-2 components, hooks, and utilities.
27+
- Deploy your Smart Contrac to a live network
28+
- Deploy your UI (`yarn vercel` or `yarn ipfs`)
29+
- You can tweak which network the frontend is pointing (and some other configurations) in `scaffold.config.ts`
30+
31+
## Smart Contract UI interactions guidelines
32+
SE-2 provides a set of hooks that facilitates contract interactions from the UI. It reads the contract data from `deployedContracts.ts` and `externalContracts.ts`, located in `packages/nextjs/contracts`.
33+
34+
### Reading data from a contract
35+
Use the `useScaffoldReadContract` (`packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts`) hook.
36+
37+
Example:
38+
```typescript
39+
const { data: someData } = useScaffoldReadContract({
40+
contractName: "YourContract",
41+
functionName: "functionName",
42+
args: [arg1, arg2], // optional
43+
});
44+
```
45+
46+
### Writing data to a contract
47+
Use the `useScaffoldWriteContract` (`packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts`) hook.
48+
1. Initilize the hook with just the contract name
49+
2. Call the `writeContractAsync` function.
50+
51+
Example:
52+
```typescript
53+
const { writeContractAsync: writeYourContractAsync } = useScaffoldWriteContract(
54+
{ contractName: "YourContract" }
55+
);
56+
// Usage (this will send a write transaction to the contract)
57+
await writeContractAsync({
58+
functionName: "functionName",
59+
args: [arg1, arg2], // optional
60+
value: parseEther("0.1"), // optional, for payable functions
61+
});
62+
```
63+
64+
Never use any other patterns for contract interaction. The hooks are:
65+
- useScaffoldReadContract (for reading)
66+
- useScaffoldWriteContract (for writing)
67+
68+
### Other Hooks
69+
SE-2 also provides other hooks to interact with blockchain data: `useScaffoldWatchContractEvent`, `useScaffoldEventHistory`, `useDeployedContractInfo`, `useScaffoldContract`, `useTransactor`. They live under `packages/nextjs/hooks/scaffold-eth`.
70+
## Display Components guidelines
71+
SE-2 provides a set of pre-built React components for common Ethereum use cases:
72+
- `Address`: Always use this when displaying an ETH address
73+
- `AddressInput`: Always use this when users need to input an ETH address
74+
- `Balance`: Display the ETH/USDC balance of a given address
75+
- `EtherInput`: An extended number input with ETH/USD conversion.
76+
77+
They live under `packages/nextjs/components/scaffold-eth`.
78+
79+
Find the relevant information from the documentation and the codebase. Think step by step before answering the question.

.github/workflows/lint.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
ci:
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest]
18+
node: [lts/*]
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@master
23+
24+
- name: Setup node env
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: ${{ matrix.node }}
28+
cache: yarn
29+
30+
- name: Install dependencies
31+
run: yarn install --immutable
32+
33+
- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
34+
run: yarn chain & yarn deploy
35+
36+
- name: Run hardhat lint
37+
run: yarn hardhat:lint --max-warnings=0
38+
39+
- name: Run nextjs lint
40+
run: yarn next:lint --max-warnings=0
41+
42+
- name: Check typings on nextjs
43+
run: yarn next:check-types

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# dependencies
2+
node_modules
3+
4+
# yarn
5+
.yarn/*
6+
!.yarn/patches
7+
!.yarn/plugins
8+
!.yarn/releases
9+
!.yarn/sdks
10+
!.yarn/versions
11+
12+
# eslint
13+
.eslintcache
14+
15+
# misc
16+
.DS_Store
17+
18+
# IDE
19+
.vscode
20+
.idea
21+
22+
# cli
23+
dist

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn lint-staged --verbose

.lintstagedrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const path = require("path");
2+
3+
const buildNextEslintCommand = (filenames) =>
4+
`yarn next:lint --fix --file ${filenames
5+
.map((f) => path.relative(path.join("packages", "nextjs"), f))
6+
.join(" --file ")}`;
7+
8+
const checkTypesNextCommand = () => "yarn next:check-types";
9+
10+
const buildHardhatEslintCommand = (filenames) =>
11+
`yarn hardhat:lint-staged --fix ${filenames
12+
.map((f) => path.relative(path.join("packages", "hardhat"), f))
13+
.join(" ")}`;
14+
15+
module.exports = {
16+
"packages/nextjs/**/*.{ts,tsx}": [
17+
buildNextEslintCommand,
18+
checkTypesNextCommand,
19+
],
20+
"packages/hardhat/**/*.{ts,tsx}": [buildHardhatEslintCommand],
21+
};

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 541 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/plugins/@yarnpkg/plugin-typescript.cjs

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-3.2.3.cjs

Lines changed: 783 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
enableColors: true
2+
3+
nmHoistingLimits: workspaces
4+
5+
nodeLinker: node-modules
6+
7+
plugins:
8+
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
9+
spec: "@yarnpkg/plugin-typescript"
10+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
11+
spec: "@yarnpkg/plugin-interactive-tools"
12+
13+
yarnPath: .yarn/releases/yarn-3.2.3.cjs

CONTRIBUTING.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Welcome to Scaffold-ETH 2 Contributing Guide
2+
3+
Thank you for investing your time in contributing to Scaffold-ETH 2!
4+
5+
This guide aims to provide an overview of the contribution workflow to help us make the contribution process effective for everyone involved.
6+
7+
## About the Project
8+
9+
Scaffold-ETH 2 is a minimal and forkable repo providing builders with a starter kit to build decentralized applications on Ethereum.
10+
11+
Read the [README](README.md) to get an overview of the project.
12+
13+
### Vision
14+
15+
The goal of Scaffold-ETH 2 is to provide the primary building blocks for a decentralized application.
16+
17+
The repo can be forked to include integrations and more features, but we want to keep the master branch simple and minimal.
18+
19+
### Project Status
20+
21+
The project is under active development.
22+
23+
You can view the open Issues, follow the development process and contribute to the project.
24+
25+
## Getting started
26+
27+
You can contribute to this repo in many ways:
28+
29+
- Solve open issues
30+
- Report bugs or feature requests
31+
- Improve the documentation
32+
33+
Contributions are made via Issues and Pull Requests (PRs). A few general guidelines for contributions:
34+
35+
- Search for existing Issues and PRs before creating your own.
36+
- Contributions should only fix/add the functionality in the issue OR address style issues, not both.
37+
- If you're running into an error, please give context. Explain what you're trying to do and how to reproduce the error.
38+
- Please use the same formatting in the code repository. You can configure your IDE to do it by using the prettier / linting config files included in each package.
39+
- If applicable, please edit the README.md file to reflect the changes.
40+
41+
### Issues
42+
43+
Issues should be used to report problems, request a new feature, or discuss potential changes before a PR is created.
44+
45+
#### Solve an issue
46+
47+
Scan through our [existing issues](https://github.com/scaffold-eth/scaffold-eth-2/issues) to find one that interests you.
48+
49+
If a contributor is working on the issue, they will be assigned to the individual. If you find an issue to work on, you are welcome to assign it to yourself and open a PR with a fix for it.
50+
51+
#### Create a new issue
52+
53+
If a related issue doesn't exist, you can open a new issue.
54+
55+
Some tips to follow when you are creating an issue:
56+
57+
- Provide as much context as possible. Over-communicate to give the most details to the reader.
58+
- Include the steps to reproduce the issue or the reason for adding the feature.
59+
- Screenshots, videos etc., are highly appreciated.
60+
61+
### Pull Requests
62+
63+
#### Pull Request Process
64+
65+
We follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr)
66+
67+
1. Fork the repo
68+
2. Clone the project
69+
3. Create a new branch with a descriptive name
70+
4. Commit your changes to the new branch
71+
5. Push changes to your fork
72+
6. Open a PR in our repository and tag one of the maintainers to review your PR
73+
74+
Here are some tips for a high-quality pull request:
75+
76+
- Create a title for the PR that accurately defines the work done.
77+
- Structure the description neatly to make it easy to consume by the readers. For example, you can include bullet points and screenshots instead of having one large paragraph.
78+
- Add the link to the issue if applicable.
79+
- Have a good commit message that summarises the work done.
80+
81+
Once you submit your PR:
82+
83+
- We may ask questions, request additional information or ask for changes to be made before a PR can be merged. Please note that these are to make the PR clear for everyone involved and aims to create a frictionless interaction process.
84+
- As you update your PR and apply changes, mark each conversation resolved.
85+
86+
Once the PR is approved, we'll "squash-and-merge" to keep the git commit history clean.

0 commit comments

Comments
 (0)