Skip to content

Commit 770611e

Browse files
Merge pull request #7 from Quantum3-Labs/develop
Update Docs
2 parents 139661c + b395aa8 commit 770611e

6 files changed

+199
-12569
lines changed

docs/intro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ slug: /
1111

1212
## About Scaffold-Stark 2
1313

14-
Scaffold-Stark is an open-source, up-to-date toolkit for building decentralized applications (dapps) on the Starknet blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts.
14+
Scaffold-Stark is an open-source, up-to-date toolkit for building decentralized applications (dapps) on the Starknet blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts. Scaffold-Stark is a UI-agnostic framework, meaning it does not enforce any specific UI framework or library, giving developers the flexibility to choose their preferred UI tools and libraries.
1515

1616
-**Contract Fast Reload**: Your frontend auto-adapts to your smart contract as you edit it.
1717
- 🔥 **Burner Wallet & Local Faucet**: Quickly test your application with a burner wallet and local faucet.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
sidebar_position: 3
3+
description: How to set up your Customize Your Own dApp
4+
---
5+
6+
# Customize Your Own dApp
7+
8+
We have two main directories that handle different parts of the project: `snfoundry` and `nextjs`.
9+
10+
The `snfoundry` directory represents the contracts section, while `nextjs` is for the frontend application.
11+
12+
These two directories together form the complete project structure, with `snfoundry` handling the backend contract logic and `nextjs` providing the frontend interface and interaction. By organizing and editing these two parts effectively, you can build a fully functional and user-friendly decentralized application.
13+
14+
15+
## Customize Contracts (snfoundry)
16+
17+
1. **Edit Smart Contract**:
18+
You can edit your smart contract file `YourContract.cairo` in the `packages/snfoundry/contracts/src` directory. This is where all the contract logic is stored. When modifying this file, ensure your contract logic meets the project requirements and is thoroughly tested before deployment.
19+
20+
2. **Deployment Scripts**:
21+
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.
22+
23+
3. **Test Smart Contracts**:
24+
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.
25+
26+
## Customize Frontend
27+
28+
### Customize Nextjs App
29+
30+
The `nextjs` directory is a critical part of your dApp, handling the frontend logic and user interface. It offers robust features and flexibility to build a dynamic and responsive application.
31+
By following these steps, you can effectively customize the pre-built components and use preset hooks to create a unique and fully functional user interface for your decentralized application.
32+
Let's dive into the main characteristics and how you can leverage them for your project.
33+
34+
1. **Edit Frontend Homepage**:
35+
You can edit your frontend homepage in `packages/nextjs/app/page.tsx`.
36+
This file is one of the entry points of your application, and modifying it will change what users see when they visit your homepage.
37+
By customizing this file, you can tailor the first impression your users get, showcasing key features and information prominently.
38+
39+
2. **Routing and Page Layouts**:
40+
Next.js supports a powerful and flexible routing system. For configuring routing and page layouts, refer to the [Next.js documentation](https://nextjs.org/docs/app/building-your-application/routing).
41+
The documentation provides detailed guides to help you define routes and configure page layouts, ensuring your application has an intuitive and powerful user interface. Next.js enables both server-side and client-side components, allowing you to build a seamless user experience.
42+
43+
3. **UI Styling**:
44+
The Next.js app supports various UI styling solutions including Tailwind CSS, CSS-in-JS (like styled-components or emotion), and traditional CSS. This flexibility allows you to choose the best styling approach that fits your project requirements and developer preferences.
45+
46+
4. **State Management**:
47+
For state management, the default solution provided is Zustand. Zustand is a small, fast, and scalable state-management solution that works well with React and Next.js. It simplifies managing global state in your application without the boilerplate often associated with other state management libraries.
48+
49+
5. **Scaffold-Stark Configuration**:
50+
The configuration for Scaffold-Stark is primarily contained in the `packages/nextjs/scaffold.config.ts` file.
51+
The folders such as utils, web3, and components under the scaffold-stark directory do not hold configurations but rather helper functions that implement the framework itself. These functions handle different aspects of the project, including utilities for smart contract interactions, web3 setup, and reusable UI components tailored for Starknet integration.
52+
These folders should mostly be untouched unless users have a deep understanding of the framework and aim to add further customization to their dApp.
53+
54+
6. **Use pre-built components and hooks**
55+
Use the preset functionality provided under the components and hooks folder to form your own business logic by further encapsulating and including hooks and components.
56+
For more details on the available components and how to use them, please refer to the [components](../components) and [Interacting with Your Smart Contracts](../hooks) section.
57+
58+
### Custom Scaffold Stark Components
59+
60+
The `components` directory, located at `packages/nextjs/components/scaffold-stark`, provides pre-built components styled with DaisyUI. These components offer a consistent and attractive design language for your application, simplifying the process of building a visually appealing frontend. However, to meet specific business needs, you might want to create custom components that wrap around these pre-built components.
61+
62+
By creating your own wrappers, you can extend and customize the functionality and appearance of these components to better fit your application's requirements. This approach allows you to leverage the base functionality and design provided by DaisyUI while adding your own business logic and custom styles.
63+
64+
Here is an example of how you can create a more complex custom component by wrapping the `Balance` component provided by Scaffold Stark:
65+
66+
```js
67+
import { Balance } from 'path/to/scaffold-stark/components';
68+
69+
const MyBalance = ({ address }) => {
70+
return (
71+
<div className="p-6 bg-white rounded-lg shadow-lg">
72+
<div className="flex items-center mb-4">
73+
<img
74+
src="/path/to/icon.png"
75+
alt="Account Icon"
76+
className="w-12 h-12 rounded-full mr-4"
77+
/>
78+
<div>
79+
<h2 className="text-2xl font-semibold">Account Balance</h2>
80+
<p className="text-gray-600">{address}</p>
81+
</div>
82+
</div>
83+
<Balance className="mt-4 text-4xl text-blue-600" address={address} />
84+
<div className="mt-2 text-sm text-gray-500">Current balance in ETH</div>
85+
</div>
86+
);
87+
};
88+
89+
export default MyBalance;
90+
```
91+
92+
In this example, the `MyBalance` component:
93+
94+
1. **Imports the Balance Component**: It starts by importing the `Balance` component from Scaffold Stark.
95+
96+
2. **Custom Styling and Structure**: It uses Tailwind CSS classes to style the component, creating a card-like layout with a header that includes an icon and the account address.
97+
98+
3. **Enhanced Presentation**: The balance is displayed prominently in a larger font size and a distinctive color, making it visually appealing. Additional information such as the account address and a small note about the balance unit is also included.
99+
100+
### Steps to Customize Your Components
101+
102+
1. **Identify the Component**:
103+
Choose the component you want to wrap from the `packages/nextjs/components/scaffold-stark` directory.
104+
105+
2. **Create a Custom Wrapper**:
106+
Create a new file in your project where you will define your custom component. Import the necessary Scaffold Stark component and wrap it with your custom logic and styles.
107+
108+
3. **Apply Custom Styles and Logic**:
109+
Use Tailwind CSS or any other styling method to apply custom styles. Add any additional logic or functionality as needed.
110+
111+
4. **Integrate with Your Application**:
112+
Use your custom component in your application wherever needed. This allows you to maintain consistency while customizing components for specific business requirements.
113+
114+
115+
### Using Scaffold Stark Hooks
116+
117+
The `hooks` directory, located at `packages/nextjs/hooks/scaffold-stark`, offers several hooks.
118+
Scaffold-Stark 2 provides a collection of custom React hooks designed to simplify interactions with your deployed smart contracts.
119+
These hooks are wrappers around Starknet-React, an easy-to-use interface with TypeScript autocompletions for reading from, writing to, and monitoring events emitted by your smart contracts.
120+
For more details, please see the [Interacting with Your Smart Contracts](../hooks) section.

docs/quick-start/environment.mdx

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ yarn deploy --network {NETWORK_NAME} // when NETWORK_NAME is not specified, it d
2929

3030
**Note:** To use sepolia tesnet, you have to set {NETWORK_NAME} to `sepolia`.
3131

32-
This command deploys a sample smart contract to the local network. The contract is located in `packages/snfoundry/contracts/src` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/snfoundry/scripts_js/deploy.js` to deploy the contract to the network. You can also customize the deploy script.
32+
This command deploys a sample smart contract to the local network. The contract is located in `packages/snfoundry/contracts/src` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/snfoundry/scripts-js/deploy.js` to deploy the contract to the network. You can also customize the deploy script.
3333

3434
### 3. Launch your NextJS Application
3535

@@ -45,5 +45,7 @@ Visit your app on: `http://localhost:3000`. You can interact with your smart con
4545

4646
- Edit your smart contract `YourContract.cairo` in `packages/snfoundry/contracts/src`.
4747
- Edit your frontend homepage at `packages/nextjs/app/page.tsx`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation.
48-
- Edit your deployment scripts in `packages/snfoundry/script-js/deploy.js`.
48+
- Edit your deployment scripts in `packages/snfoundry/script-ts/deploy.ts`.
4949
- Edit your smart contract test in: `packages/snfoundry/contracts/src/test`. To run test use `yarn test`.
50+
51+
see more detail at [customize-your-own-dApp](./customize-your-own-dApp) to customize your own dApp.

docs/quick-start/installation.mdx

+72-10
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Before you begin, you need to install the following tools:
1515

1616
## Install scarb
1717

18-
To ensure the proper functioning of scaffold-stark, your local `Scarb` version must be `2.5.4`. To accomplish this, first check your local Scarb version:
18+
To ensure the proper functioning of scaffold-stark, your local `Scarb` version must be `2.6.5`. To accomplish this, first check your local Scarb version:
1919

2020
```sh
2121
scarb --version
2222
```
2323

24-
If your local Scarb version is not `2.5.4`, you need to install it.
24+
If your local Scarb version is not `2.6.5`, you need to install it.
2525

2626
<details>
2727
<summary><b>Scarb Installation Process</b></summary>
@@ -42,34 +42,96 @@ Once you have `asdf` installed locally, you can download Scarb plugin with the f
4242
asdf plugin add scarb
4343
```
4444

45-
This will allow you to download specific versions. You can choose the same version as the Dojo's Cairo version, for example, 2.5.4, with the following command:
45+
This will allow you to download specific versions. You can choose the same version as the Dojo's Cairo version, for example, 2.6.5, with the following command:
4646

4747
```bash
48-
asdf install scarb 2.5.4
48+
asdf install scarb 2.6.5
4949
```
5050

5151
and set a global version:
5252

5353
```bash
54-
asdf global scarb 2.5.4
54+
asdf global scarb 2.6.5
5555
```
5656

5757
Otherwise, you can simply run the following command in your terminal, and follow the onscreen instructions. This
58-
will install the version `2.5.4` of Scarb.
58+
will install the version `2.6.5` of Scarb.
5959

6060
```bash
61-
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.5.4
61+
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.6.5
6262
```
6363

6464
</details>
6565

66+
## Install `starknet-devnet`
67+
68+
To ensure the proper functioning of scaffold-stark, your local starknet-devnet version must be 0.0.4.
69+
To accomplish this, first check your local starknet-devnet version:
70+
71+
```
72+
starknet-devnet --version
73+
```
74+
75+
If your local starknet-devnet version is not `0.0.4`, you need to install it.
76+
77+
```sh
78+
cargo install starknet-devnet --version 0.0.4
79+
```
80+
81+
## Install Starknet Foundry
82+
83+
If your Starknet Foundry version is not 0.27.0, you need to install it.
84+
85+
```sh
86+
snforge --version
87+
```
88+
89+
<details>
90+
<summary><b>Scarb Installation Process</b></summary>
91+
92+
To install Starknet Foundry, please refer to the [installation instructions](https://foundry-rs.github.io/starknet-foundry/getting-started/installation.html#installation-via-asdf).
93+
We strongly recommend that you install Scarb via [asdf](https://docs.swmansion.com/scarb/download.html#install-via-asdf).
94+
95+
Once you have `asdf` installed locally, you can download Scarb plugin with the following command:
96+
97+
```bash
98+
asdf plugin add starknet-foundry
99+
```
100+
101+
This will allow you to download specific versions.
102+
103+
```bash
104+
asdf install starknet-foundry 0.27.0
105+
```
106+
107+
and set a global version:
108+
109+
```bash
110+
asdf global starknet-foundry 0.27.0
111+
```
112+
</details>
113+
114+
115+
## Install RPC
116+
117+
To ensure the proper functioning of the scaffold-stark with Testnet or Mainnet, your RPC version must be `0.7.0`. This repository contains a .env.example file, where we provided the default RPC URL for the Starknet Testnet: `RPC_URL_SEPOLIA=https://starknet-sepolia.public.blastapi.io/rpc/v0_7`. Let's verify this RPC version is `0.7.0` by running the following command:
118+
119+
```sh
120+
curl --location 'https://starknet-sepolia.public.blastapi.io/rpc/v0_7' \
121+
--data '{
122+
"jsonrpc":"2.0",
123+
"method":"starknet_specVersion",
124+
"id":1
125+
}'
126+
```
127+
66128
## Compatible versions
67129

68-
- scarb - v2.5.4
69-
- cairo - v2.5.4
130+
- scarb - v2.6.5
131+
- cairo - v2.6.4
70132
- starknet - v2.5.4
71133
- sierra - v1.4.0
72-
- rpc - v0.5.1
134+
- rpc - v0.7.0
73135

74136
## Setup
75137

0 commit comments

Comments
 (0)