Skip to main content

Environment Setup

Now that our installation is complete, let's configure the development environment for Scaffold Stark.

1. Initialize a Local Blockchain:โ€‹

Run a local network in the first terminal.

Note: You can skip this step if you want to use Sepolia Testnet.

yarn chain

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.

2. Deploy your smart contract:โ€‹

In the second terminal, deploy the test contract:

yarn deploy

Note: To deploy to sepolia testnet, you have to run yarn deploy --network sepolia.

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.

The command also will create a file called packages/nextjs/contracts/deployedContracts.ts within the Next.js App, which would be the ABI source-of-truth for the Scaffold Hooks. This enables autocomplete to be activated when you are building the Next.js front-end of the application.

tip

Note that yarn deploy resets the generated deployedContracts.ts file be default. To keep the existing deployments and deployedContracts.ts, you can run:

yarn deploy:no-reset

3. Launch your NextJS Applicationโ€‹

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.

What's next:

  • Edit your smart contract your_contract.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 test in: packages/snfoundry/contracts/src/test. To run test use yarn test.

See more details at the Customize Your Own dApp page!