Skip to main content

Developing on Fork

This guide shows how to run and interact with a local fork of Starknet mainnet.

Setupโ€‹

  1. Start the fork:
yarn chain --fork-network https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_8
  1. After running yarn chain fork, there will be a block number in console:
Forking from block: number=1047693
  1. If you wanna use events, MAKE SURE the fromBlock is a number bigger than the number in console + 1, otherwise the events data will always be empty. i.e. do not capture the first block of the fork
const { data: events } = useScaffoldEventHistory({
contractName: "YourContract",
eventName: "GreetingChanged",
fromBlock: 1028886n, // NOTE : Use the latest block on the fork + 1 ( see the logs in the console)
watch: true,
});
  1. Update scaffoldConfig in scaffold.config.ts as:
const scaffoldConfig = {
targetNetworks: [chains.mainnetFork],
// ... other config options
};
  1. Create a .env file from the .env.example template and configure it accordingly
NEXT_PUBLIC_PROVIDER_URL=http://127.0.0.1:5050

Wallet Configurationโ€‹

Using Argent/Braavosโ€‹

  1. Open your wallet
  2. Add Custom Network:

image

tip

As of the latest of this documentation, Bravoos has yet to add support for adding custom network. you can connect to devnet manually in Bravoos.

Interactionโ€‹

Navigate to /debug-ui to interact with your contracts

Notesโ€‹

  • Make sure your contract deployment is complete before testing
  • The burner wallet is automatically configured with test STRK
  • External wallets need to be configured with the correct network settings