Skip to content

Commit 4a0e951

Browse files
Merge pull request #78 from Scaffold-Stark/bu/update-deploy-flag
Add deploy flag to Customize Your Own dApp
2 parents 52301b8 + 96f86d5 commit 4a0e951

7 files changed

+115
-60
lines changed

docs/components/Balance.md

+8-13
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,24 @@ import { Balance } from "~~/components/scaffold-stark";
2828

2929
## Props
3030

31-
| Prop | Type | Default Value | Description |
32-
| ------------------------ | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
33-
| **address** | `string` | `undefined` | Address in `0x___` format, it will resolve its Starknet Domain if it has one associated(coming soon). |
34-
| **className** (optional) | `string` | `""` | Prop to pass additional CSS styling to the component. You can use Tailwind / daisyUI classes like `text-3xl` for styling. |
35-
| **usdMode** (optional) | `boolean` | `false` | If true, the balance is displayed in USD. Otherwise, it defaults to ETH/STRK. |
36-
31+
| Prop | Type | Default Value | Description |
32+
| ------------------------ | --------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
33+
| **address** | `string` | `undefined` | Address in `0x___` format, it will resolve its Starknet Domain if it has one associated(coming soon). |
34+
| **className** (optional) | `string` | `""` | Prop to pass additional CSS styling to the component. You can use Tailwind / daisyUI classes like `text-3xl` for styling. |
35+
| **usdMode** (optional) | `boolean` | `false` | If true, the balance is displayed in USD. Otherwise, it defaults to ETH/STRK. |
3736

3837
## Example
3938

4039
The `Balance` component can be easily customized using Tailwind or daisyUI classes. Here’s a more detailed example of its usage:
4140

4241
```tsx
43-
<Balance
44-
address="0x34aA3F359A9D614239015126635CE7732c18fDF3"
45-
className="text-lg text-gray-700 mt-4"
46-
usdMode={true}
47-
/>
42+
<Balance address="0x34aA3F359A9D614239015126635CE7732c18fDF3" className="text-lg text-gray-700 mt-4" usdMode={true} />
4843
```
4944

5045
This example showcases how to apply additional styling to the component and enables the USD display mode.
5146

52-
5347
:::info
48+
5449
- The component automatically handles loading states, showing a skeleton loader when the balance is being fetched.
5550
- If the address is invalid or no balance is found, it will show an error message.
56-
:::
51+
:::

docs/hooks/useScaffoldStrkBalance.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ This example demonstrates how to use the `useScaffoldStrkBalance` hook to displa
3131

3232
## Configuration
3333

34-
| Parameter | Type | Description |
35-
| :------------- | :--------------------- | :---------------------------------------------------------------------------------------------- |
36-
| **address** | `Address \| string` | The STRK address to fetch the balance for. If not provided, it will attempt to fetch the balance for the current connected account. |
34+
| Parameter | Type | Description |
35+
| :---------- | :------------------ | :---------------------------------------------------------------------------------------------------------------------------------- |
36+
| **address** | `Address \| string` | The STRK address to fetch the balance for. If not provided, it will attempt to fetch the balance for the current connected account. |
3737

3838
## Return Values
3939

40-
| Parameter | Type | Description |
41-
| :--------------- | :------------ | :------------------------------------------------------------------------------------------------------------- |
42-
| **value** | `bigint` | The raw STRK balance fetched from the contract as a `bigint`. |
43-
| **decimals** | `number` | Number of decimals for the token. Defaults to `18` for STRK. |
44-
| **symbol** | `string` | The token symbol. For this contract, it will return `"STRK"`. |
45-
| **formatted** | `string` | The balance formatted into a human-readable string using ethers' `formatUnits`. |
46-
| **error** | `Error` | Error object in case there is a failure fetching the balance. |
40+
| Parameter | Type | Description |
41+
| :------------ | :------- | :------------------------------------------------------------------------------ |
42+
| **value** | `bigint` | The raw STRK balance fetched from the contract as a `bigint`. |
43+
| **decimals** | `number` | Number of decimals for the token. Defaults to `18` for STRK. |
44+
| **symbol** | `string` | The token symbol. For this contract, it will return `"STRK"`. |
45+
| **formatted** | `string` | The balance formatted into a human-readable string using ethers' `formatUnits`. |
46+
| **error** | `Error` | Error object in case there is a failure fetching the balance. |
4747

4848
## Best Practices
4949

docs/quick-start/customize-your-own-dApp.mdx

+55
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,61 @@ These two directories together form the complete project structure, with `snfoun
1919
2. **Deployment Scripts**:
2020
The deployment scripts are located in `packages/snfoundry/scripts-ts/deploy.ts`. This script is used to deploy your smart contract to the specified blockchain network. By editing this script, you can adjust the deployment process, such as specifying different networks or contract parameters.
2121

22+
#### Deployment Command Line Flags
23+
24+
The deployment script supports several command line flags to customize the deployment process:
25+
26+
#### --network
27+
28+
- Type: string
29+
- Default: "devnet"
30+
- Description: Specifies the network for deployment
31+
- Example: `--network mainnet`
32+
33+
<br />
34+
35+
#### --fee
36+
37+
- Type: string
38+
- Default: "eth"
39+
- Choices:
40+
- "eth": Use ETH as the fee token
41+
- "strk": Use STRK as the fee token
42+
- Example: `--fee strk`
43+
44+
<br />
45+
46+
#### --reset
47+
48+
- Type: boolean
49+
- Default: true
50+
- Description: Controls whether to reset existing deployments
51+
- When true: Keeps existing deployments
52+
- When false: Resets deployments before new deployment
53+
- Example: `--reset false`
54+
55+
<br />
56+
57+
#### Example Commands
58+
59+
2.1. Deploy to devnet using ETH fees (default settings):
60+
61+
```bash
62+
yarn deploy
63+
```
64+
65+
2.2. Deploy to testnet using STRK fees:
66+
67+
```bash
68+
yarn deploy --network sepolia --fee strk
69+
```
70+
71+
2.3. Deploy with reset:
72+
73+
```bash
74+
yarn deploy --network sepolia --reset false
75+
```
76+
2277
3. **Test Smart Contracts**:
2378
To ensure your smart contracts work correctly, write and run tests in the `packages/snfoundry/contracts/src/test` directory. These tests can be executed using the `yarn test` command. This helps catch and fix potential errors before deployment.
2479

docs/quick-start/installation.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ curl --location 'https://starknet-sepolia.public.blastapi.io/rpc/v0_7' \
136136
| starknet-devnet | v0.2.3 |
137137
| snforge | v0.34.0 |
138138
| starknet.js | v6.12.1 |
139-
| starknet-react | v3.6.0 |
139+
| starknet-react | v3.6.0 |
140140

141141
## Setup
142142

docs/recipes/DevelopingOnFork.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,47 @@ This guide shows how to run and interact with a local fork of Starknet mainnet.
55
## Setup
66

77
1. Start the fork:
8+
89
```bash
910
yarn chain --fork-network https://starknet-mainnet.public.blastapi.io/rpc/v0_7
1011
```
1112

12-
2. Update `scaffoldConfig` in scaffold.config.ts as:
13+
2. After running yarn chain fork, there will be a block number in console:
14+
15+
```bash
16+
Forking from block: number=1047693
17+
```
18+
19+
3. If you wanna use events, **MAKE SURE** the fromBlock : is > the number in console + 1, otherwise the events data will always be empty. i.e. do not capture the first block of the fork
20+
21+
```typescript
22+
const { data: events } = useScaffoldEventHistory({
23+
contractName: "YourContract",
24+
eventName: "contracts::YourContract::YourContract::GreetingChanged",
25+
fromBlock: 1028886n, // NOTE : Use the latest block on the fork + 1 ( see the logs in the console)
26+
watch: true,
27+
});
28+
```
29+
30+
4. Update `scaffoldConfig` in scaffold.config.ts as:
31+
1332
```typescript
1433
const scaffoldConfig = {
1534
targetNetworks: [chains.mainnetFork],
16-
isFork: true, // handles forked network validation
1735
// ... other config options
1836
};
1937
```
2038

21-
3. Create a `.env` file from the `.env.example` template and configure it accordingly
39+
5. Create a `.env` file from the `.env.example` template and configure it accordingly
40+
2241
```
2342
NEXT_PUBLIC_PROVIDER_URL=http://127.0.0.1:5050
2443
```
2544

2645
## Wallet Configuration
2746

2847
### Using Argent/Braavos
48+
2949
1. Open your wallet
3050
2. Add Custom Network:
3151
- RPC URL: http://127.0.0.1:5050/rpc
@@ -34,16 +54,16 @@ NEXT_PUBLIC_PROVIDER_URL=http://127.0.0.1:5050
3454

3555
![image](https://github.com/user-attachments/assets/511b84a1-e232-46b3-a4a4-82c44ad03969)
3656

37-
3857
similiarly for braavos.
3958
if you correctly connected with the devnet correctly, it should show
4059
![image](https://github.com/user-attachments/assets/a684c853-35ed-4042-a415-86744efb36d2)
4160

42-
4361
## Interaction
62+
4463
Navigate to `/debug-ui` to interact with your contracts
4564

4665
## Notes
66+
4767
- Make sure your contract deployment is complete before testing
4868
- The burner wallet is automatically configured with test ETH
49-
- External wallets need to be configured with the correct network settings
69+
- External wallets need to be configured with the correct network settings

docs/recipes/MultiWriteFeature.md

+14-29
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: Learn how to perform multiple write operations to StarkNet smart co
99
This recipe shows how to perform multiple contract write operations in a single transaction using the [`useScaffoldMultiWriteContract`](https://github.com/Scaffold-Stark/scaffold-stark-2/blob/main/packages/nextjs/hooks/scaffold-stark/useScaffoldMultiWriteContract.ts) hook from Scaffold-Stark.
1010

1111
## Overview
12+
1213
In this guide, we will implement a feature that allows writing to multiple contracts or executing multiple transactions in a single action. This is particularly useful when your decentralized application (dApp) requires multiple state changes at once.
1314

1415
This documentation will walk through the code and steps necessary to create a button that triggers the multi-write contract interaction.
@@ -56,30 +57,22 @@ export const MultiSetData = () => {
5657
type="text"
5758
placeholder="Enter your name"
5859
className="input border border-primary"
59-
onChange={(e) => setName(e.target.value)}
60+
onChange={e => setName(e.target.value)}
6061
/>
6162
<input
6263
type="number"
6364
placeholder="Enter your age"
6465
className="input border border-primary"
65-
onChange={(e) => setAge(Number(e.target.value))}
66+
onChange={e => setAge(Number(e.target.value))}
6667
/>
67-
<button
68-
className="btn btn-primary"
69-
onClick={handleSetData}
70-
disabled={isPending}
71-
>
72-
{isPending ? (
73-
<span className="loading loading-spinner loading-sm"></span>
74-
) : (
75-
"Submit"
76-
)}
68+
<button className="btn btn-primary" onClick={handleSetData} disabled={isPending}>
69+
{isPending ? <span className="loading loading-spinner loading-sm"></span> : "Submit"}
7770
</button>
7871
</div>
7972
);
8073
};
81-
8274
```
75+
8376
</details>
8477

8578
## Implementation Guide
@@ -88,11 +81,10 @@ export const MultiSetData = () => {
8881

8982
Create a new component in your `component` folder, named `MultiContractInteraction.tsx`. This component will handle multiple write operations on different contracts
9083

91-
9284
```tsx title="components/MultiContractInteraction.tsx"
9385
export const MultiContractInteraction = () => {
94-
return <div>Your MultiContractInteraction</div>
95-
}
86+
return <div>Your MultiContractInteraction</div>;
87+
};
9688
```
9789

9890
### Step 2: Import Required Hooks and Utilities
@@ -134,12 +126,12 @@ const { sendAsync, isPending } = useScaffoldMultiWriteContract({
134126
},
135127
],
136128
});
137-
138129
```
139130

140131
- The `isPending` variable will manage the loading state of the button, and `sendAsync` will handle the contract transaction.
141132

142133
### Step 5: Handle Submission
134+
143135
- Create a `handleSetData` function that triggers the multi-write action. If successful, display a success notification; otherwise, log the error and display a failure message.
144136

145137
```tsx title="components/MultiContractInteraction.tsx"
@@ -155,6 +147,7 @@ const handleSetData = async () => {
155147
```
156148

157149
### Step 6: Create the UI
150+
158151
- Add inputs for `name` and `age`, and a button to submit the data.
159152
- Disable the button while the transaction is pending.
160153

@@ -165,24 +158,16 @@ return (
165158
type="text"
166159
placeholder="Enter your name"
167160
className="input border border-primary"
168-
onChange={(e) => setName(e.target.value)}
161+
onChange={e => setName(e.target.value)}
169162
/>
170163
<input
171164
type="number"
172165
placeholder="Enter your age"
173166
className="input border border-primary"
174-
onChange={(e) => setAge(Number(e.target.value))}
167+
onChange={e => setAge(Number(e.target.value))}
175168
/>
176-
<button
177-
className="btn btn-primary"
178-
onClick={handleSetData}
179-
disabled={isPending}
180-
>
181-
{isPending ? (
182-
<span className="loading loading-spinner loading-sm"></span>
183-
) : (
184-
"Submit"
185-
)}
169+
<button className="btn btn-primary" onClick={handleSetData} disabled={isPending}>
170+
{isPending ? <span className="loading loading-spinner loading-sm"></span> : "Submit"}
186171
</button>
187172
</div>
188173
);

docusaurus.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4-
const dotenv = require('dotenv'); // Import dotenv
4+
const dotenv = require("dotenv"); // Import dotenv
55
dotenv.config(); // Load environment variables
66

77
const lightCodeTheme = require("prism-react-renderer/themes/github");

0 commit comments

Comments
 (0)