This README provides instructions for setting up a local development environment for StarkNet using the StarkNet Devnet and Protostar tools.
Before proceeding, ensure you have Docker installed on your system.
Start the StarkNet Devnet using Docker with the following command:
docker run -p 5050:5050 shardlabs/starknet-devnet-rs --seed 0This command runs the StarkNet Devnet on port 5050 and initializes it with a seed value of 0.
To deploy contracts using Protostar, follow these steps:
-
Build the Contract:
Build your contract using the
protostar build-cairo0command:protostar build-cairo0
This command compiles your Cairo contracts and prepares them for deployment.
-
Set Environment Variable:
Set the
PROTOSTAR_ACCOUNT_PRIVATE_KEYenvironment variable to your private key:export PROTOSTAR_ACCOUNT_PRIVATE_KEY=0x71d7bb07b9a64f6f78ac4c816aff4da9 -
Deploy the Contract:
Use the
protostar declare-cairo0command to deploy your contract:protostar declare-cairo0 --account-address 0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691 --max-fee auto --gateway-url http://localhost:5050/ --chain-id 1536727068981429685321 build/main.json
This command deploys your contract (specified in
build/main.json) to the local StarkNet chain.
- The
--seedparameter in thedocker runcommand is used to initialize the blockchain with a deterministic state. - The
PROTOSTAR_ACCOUNT_PRIVATE_KEYshould be kept secure and not shared. - The
--account-addressin theprotostarcommand should be replaced with your account address. - The
--chain-idspecifies the chain ID for the StarkNet network.
These instructions set up a local development environment for StarkNet, allowing you to deploy and test smart contracts locally.