Skip to content

Scaffold-Stark/scaffold-stark-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ— Scaffold-Stark

πŸ§ͺ An open-source, up-to-date toolkit for building decentralized applications (dapps) on 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.

βš™οΈ Built using NextJS, Starknet.js, Scarb, Starknet-React, Starknet Foundry and Typescript.

  • βœ… Contract Fast Reload: Your frontend auto-adapts to your smart contracts as you deploy them.
  • πŸͺ Custom hooks: Collection of React hooks wrapper around starknet-react to simplify interactions with smart contracts with typescript autocompletion.
  • 🧱 Components: Collection of common web3 components to quickly build your frontend.
  • πŸ”₯ Burner Wallet & Prefunded Account: Quickly test your application with a burner wallet and prefunded accounts.
  • πŸ” Integration with Wallet Providers: Connect to different wallet providers and interact with Starknet network.

Debug Contracts tab

Requirements

Before you begin, you need to install the following tools:

Starknet-devnet version

To ensure the proper functioning of scaffold-stark, your local starknet-devnet version must be 0.2.3. To accomplish this, first check your local starknet-devnet version:

starknet-devnet --version

If your local starknet-devnet version is not 0.2.3, you need to install it.

Scarb version

To ensure the proper functioning of scaffold-stark, your local Scarb version must be 2.9.2. To accomplish this, first check your local Scarb version:

scarb --version

If your local Scarb version is not 2.9.2, you need to install it.

Starknet Foundry version

To ensure the proper functioning of the tests on scaffold-stark, your Starknet Foundry version must be 0.31.0. To accomplish this, first check your Starknet Foundry version:

snforge --version

If your Starknet Foundry version is not 0.34.0, you need to install it.

Compatible versions

  • Starknet-devnet - v0.2.3
  • Scarb - v2.9.2
  • Snforge - v0.34.0
  • Cairo - v2.9.2
  • Rpc - v0.7.1

Quickstart with Starknet-Devnet

To get started with Scaffold-Stark, follow the steps below:

  1. Clone this repo and install dependencies
git clone https://github.com/Scaffold-Stark/scaffold-stark-2.git
cd scaffold-stark-2
yarn install
  1. Run a local network in the first terminal.
yarn chain

To run a fork : yarn chain --fork-network <URL> [--fork-block <BLOCK_NUMBER>]

This command starts a local Starknet network using Devnet. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in scaffold.config.ts for your nextjs app.

  1. On a second terminal, deploy the sample contract:
yarn deploy

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-ts/deploy.ts to deploy the contract to the network. You can also customize the deploy script.

By default Scaffold-Stark takes the first prefunded account from starknet-devnet as a deployer address,

  1. On a third terminal, start your NextJS app:
yarn start

Visit your app on: http://localhost:3000. You can interact with your smart contract using the Debug Contracts page. You can tweak the app config in packages/nextjs/scaffold.config.ts.

  1. Check your environment variables. We have a yarn postinstall script that helps to fill in your environment variables. If the environment variable does not exist, you can fill them it manually to get the app running!

Quickstart with Sepolia Testnet

  1. Make sure you alredy cloned this repo and installed dependencies.

  2. Prepare your environment variables.

Find the packages/snfoundry/.env file and fill the env variables related to Sepolia testnet with your own wallet account contract address and private key.

  1. Change your default network to Sepolia testnet.

Find the packages/nextjs/scaffold.config.ts file and change the targetNetworks to [chains.sepolia].

chall-0-scaffold-config

  1. Get some testnet tokens.

You will need to get some ETH or STRK Sepolia tokens to deploy your contract to Sepolia testnet.

Some popular faucets are Starknet Faucet and Blastapi Starknet Sepolia Eth

  1. Open a terminal, deploy the sample contract to Sepolia testnet:
yarn deploy --network sepolia
  1. On a second terminal, start your NextJS app:
yarn start

Visit your app on: http://localhost:3000. You can interact with your smart contract using the Debug Contracts page. You can tweak the app config in packages/nextjs/scaffold.config.ts.

RPC specific version

To ensure the proper functioning of the scaffold-stark with Testnet or Mainnet, your RPC version must be 0.7.1. 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.1 by calling a POST request in an API platform like Postman or Insommia . Your API endpoint should be https://starknet-sepolia.public.blastapi.io/rpc/v0_7 and the body should be:

{
 "jsonrpc":"2.0",
 "method":"starknet_specVersion",
 "id":1
}

You have to paste the endpoint and body in the API platform and click on the Send button. If the response is 0.7.1, then you are good to go. Otherwise, you have to get the correct RPC URL endpoint.

rpc-version

What's next

  • Edit your smart contract YourContract.cairo in packages/snfoundry/contracts/src
  • Edit your frontend homepage at packages/nextjs/app/page.tsx. For guidance on routing and configuring pages/layouts checkout the Next.js documentation.
  • Edit your deployment scripts in packages/snfoundry/script-ts/deploy.ts
  • Edit your smart contract tests in packages/snfoundry/contracts/src/test. To run tests use yarn test
  • You can write unit tests for your Next.js app! Run them with one the following scripts below.
    • yarn test:nextjs to run regular tests with watch mode
    • yarn test:nextjs run to run regular tests without watch mode
    • yarn test:nextjs run --coverage to run regular tests without watch mode with coverage

Documentation

Visit our docs to learn how to start building with Scaffold-Stark.

To know more about its features, check out our website

External Image Source Configuration

In the next.config.mjs, we've set up external image sources using remotePatterns to allow fetching assets from specific domains. This is particularly useful for loading images or assets from external servers or services.

remotePatterns: [
  // External image source for StarkNet ID identicons
  {
    protocol: "https",
    hostname: "identicon.starknet.id",
    pathname: "/**", // Allows all paths under this domain
  },
  // External image source for images hosted on Starkurabu
  {
    protocol: "https",
    hostname: "img.starkurabu.com",
    pathname: "/**",
  },
],

Contributing to Scaffold-Stark

We welcome contributions to Scaffold-Stark!

Please see CONTRIBUTING.MD for more information and guidelines for contributing to Scaffold-Stark.