Skip to content

Commit 8559181

Browse files
authored
Initial commit
0 parents  commit 8559181

File tree

152 files changed

+30489
-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.

152 files changed

+30489
-0
lines changed

.cursor/rules/scaffold-eth.mdc

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
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.
7+
8+
It's a yarn monorepo that contains two main packages:
9+
10+
- Hardhat (`packages/hardhat`): The solidity framework to write, test and deploy EVM Smart Contracts.
11+
- NextJS (`packages/nextjs`): The UI framework extended with utilities to make interacting with Smart Contracts easy (using Next.js App Router, not Pages Router).
12+
13+
The usual dev flow is:
14+
15+
- Start SE-2 locally:
16+
- `yarn chain`: Starts a local blockchain network
17+
- `yarn deploy`: Deploys SE-2 default contract
18+
- `yarn start`: Starts the frontend
19+
- Write a Smart Contract (modify the deployment script in `packages/hardhat/deploy` if needed)
20+
- Deploy it locally (`yarn deploy`)
21+
- Go to the `http://locahost:3000/debug` page to interact with your contract with a nice UI
22+
- Iterate until you get the functionality you want in your contract
23+
- Write tests for the contract in `packages/hardhat/test`
24+
- Create your custom UI using all the SE-2 components, hooks, and utilities.
25+
- Deploy your Smart Contrac to a live network
26+
- Deploy your UI (`yarn vercel` or `yarn ipfs`)
27+
- You can tweak which network the frontend is poiting (and some other configurations) in `scaffold.config.ts`
28+
29+
## Smart Contract UI interactions guidelines
30+
31+
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`.
32+
33+
### Reading data from a contract
34+
Use the `useScaffoldReadContract` (`packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts`) hook. Example:
35+
36+
```typescript
37+
const { data: someData } = useScaffoldReadContract({
38+
contractName: "YourContract",
39+
functionName: "functionName",
40+
args: [arg1, arg2], // optional
41+
});
42+
```
43+
44+
### Writing data to a contract
45+
Use the `useScaffoldWriteContract` (`packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts`) hook.
46+
1. Initilize the hook with just the contract name
47+
2. Call the `writeContractAsync` function.
48+
49+
Example:
50+
51+
```typescript
52+
const { writeContractAsync: writeYourContractAsync } = useScaffoldWriteContract(
53+
{ contractName: "YourContract" }
54+
);
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+
66+
- useScaffoldReadContract (for reading)
67+
- useScaffoldWriteContract (for writing)
68+
69+
### Other Hooks
70+
SE-2 also provides other hooks to interact with blockchain data: `useScaffoldWatchContractEvent`, `useScaffoldEventHistory`, `useDeployedContractInfo`, `useScaffoldContract`, `useTransactor`. They live under `packages/nextjs/hooks/scaffold-eth`.
71+
72+
## Display Components guidelines
73+
SE-2 provides a set of pre-built React components for common Ethereum use cases:
74+
- `Address`: Always use this when displaying an ETH address
75+
- `AddressInput`: Always use this when users need to input an ETH address
76+
- `Balance`: Display the ETH/USDC balance of a given address
77+
- `EtherInput`: An extended number input with ETH/USD conversion.
78+
79+
They live under `packages/nextjs/components/scaffold-eth`.
80+
81+
Find the relevant information from the documentation and the codebase. Think step by step before answering the question.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Bug Report
2+
description: File a bug/issue
3+
title: 'bug: <title>'
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this bug report! The more info you provide, the more we can help you 🙌
9+
10+
- type: checkboxes
11+
attributes:
12+
label: Is there an existing issue for this?
13+
description: Please search to see if an issue already exists for the bug you encountered.
14+
options:
15+
- label: I have looked through the [existing issues](https://github.com/scaffold-eth/scaffold-eth-2/issues)
16+
required: true
17+
18+
- type: dropdown
19+
attributes:
20+
label: Which method was used to setup Scaffold-ETH 2 ?
21+
description: You may select both, if the bug is present in both the methods.
22+
multiple: true
23+
options:
24+
- git clone
25+
- npx create-eth@latest
26+
validations:
27+
required: true
28+
29+
- type: textarea
30+
attributes:
31+
label: Current Behavior
32+
description: A concise description of what you're experiencing.
33+
validations:
34+
required: false
35+
36+
- type: textarea
37+
attributes:
38+
label: Expected Behavior
39+
description: A concise description of what you expected to happen.
40+
validations:
41+
required: false
42+
43+
- type: textarea
44+
attributes:
45+
label: Steps To Reproduce
46+
description: Steps or code snippets to reproduce the behavior.
47+
validations:
48+
required: false
49+
50+
- type: textarea
51+
attributes:
52+
label: Anything else?
53+
description: |
54+
Browser info? Screenshots? Anything that will give us more context about the issue you are encountering!
55+
56+
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
57+
validations:
58+
required: false

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Ask Question
4+
url: https://github.com/scaffold-eth/scaffold-eth-2/discussions/new?category=q-a
5+
about: Ask questions and discuss with other community members
6+
- name: Request Feature
7+
url: https://github.com/scaffold-eth/scaffold-eth-2/discussions/new?category=ideas
8+
about: Requests features or brainstorm ideas for new functionality

.github/pull_request_template.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Description
2+
3+
_Concise description of proposed changes, We recommend using screenshots and videos for better description_
4+
5+
## Additional Information
6+
7+
- [ ] I have read the [contributing docs](/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) (if this is your first contribution)
8+
- [ ] This is not a duplicate of any [existing pull request](https://github.com/scaffold-eth/scaffold-eth-2/pulls)
9+
10+
## Related Issues
11+
12+
_Closes #{issue number}_
13+
14+
_Note: If your changes are small and straightforward, you may skip the creation of an issue beforehand and remove this section. However, for medium-to-large changes, it is recommended to have an open issue for discussion and approval prior to submitting a pull request._
15+
16+
Your ENS/address:

.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 nextjs lint
37+
run: yarn next:lint --max-warnings=0
38+
39+
- name: Check typings on nextjs
40+
run: yarn next:check-types
41+
42+
- name: Run hardhat lint
43+
run: yarn hardhat:lint --max-warnings=0

.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+
};

0 commit comments

Comments
 (0)