Skip to content

Commit f94c6c3

Browse files
authored
Update cursor rules (scaffold-ui) (#1195)
1 parent 5acf3d2 commit f94c6c3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

.cursor/rules/scaffold-eth.mdc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
2-
description:
3-
globs:
2+
description:
3+
globs:
44
alwaysApply: true
55
---
6+
67
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.
78

89
It's a yarn monorepo that contains two main packages:
@@ -31,6 +32,7 @@ The usual dev flow is:
3132
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`.
3233

3334
### Reading data from a contract
35+
3436
Use the `useScaffoldReadContract` (`packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts`) hook. Example:
3537

3638
```typescript
@@ -42,11 +44,13 @@ const { data: someData } = useScaffoldReadContract({
4244
```
4345

4446
### Writing data to a contract
47+
4548
Use the `useScaffoldWriteContract` (`packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts`) hook.
49+
4650
1. Initilize the hook with just the contract name
4751
2. Call the `writeContractAsync` function.
4852

49-
Example:
53+
Example:
5054

5155
```typescript
5256
const { writeContractAsync: writeYourContractAsync } = useScaffoldWriteContract(
@@ -100,15 +104,18 @@ The `data` property consists of an array of events and can be displayed as:
100104
```
101105

102106
### Other Hooks
107+
103108
SE-2 also provides other hooks to interact with blockchain data: `useScaffoldWatchContractEvent`, `useScaffoldEventHistory`, `useDeployedContractInfo`, `useScaffoldContract`, `useTransactor`. They live under `packages/nextjs/hooks/scaffold-eth`.
104109

105110
## Display Components guidelines
106-
SE-2 provides a set of pre-built React components for common Ethereum use cases:
111+
112+
With the `@scaffold-ui/components` library, SE-2 provides a set of pre-built React components for common Ethereum use cases:
113+
107114
- `Address`: Always use this when displaying an ETH address
108115
- `AddressInput`: Always use this when users need to input an ETH address
109116
- `Balance`: Display the ETH/USDC balance of a given address
110117
- `EtherInput`: An extended number input with ETH/USD conversion.
111118

112-
They live under `packages/nextjs/components/scaffold-eth`.
119+
For fully customizable components, you can use the hooks from the `@scaffold-ui/hooks` library to get the data you need.
113120

114121
Find the relevant information from the documentation and the codebase. Think step by step before answering the question.

0 commit comments

Comments
 (0)