Create a simple Clarity contract to deploy to devnet
Spin up a local blockchain using the Clarinet CLI
Create a new project
To demonstrate how to run a local blockchain, we'll need a project to work with. If you don't already have one, we can create a simple hello-world project below.
This will create a new directory with our project already configured.
Create a new contract
Before we spin up our local blockchain, we should deploy something to it - let's go ahead and change directories into our project and create a hello contract.
In our new hello.clar file, let's add a few functions: say-hi, echo-number, and check-it.
Run a local blockchain with clarinet devnet start
We're now ready to start up our local blockchain and deploy our hello-world contract. Run the following command and let's walkthrough what's happening under the hood.
At this point, clarinet will start creating a deployment plan for your devnet network and begin spinning up all the necessary services required and deploying our hello contract.
Common errors
If you are getting error: clarinet was unable to create network, make sure you have Docker (or a similar service) installed and running locally. Check out the Docker installation guide for more details.
Next step: Connect your local devnet to a web wallet
Now that you have a local devnet running on your machine, it would be nice to be able to interact with your local contracts deployed to that network from a frontend application. This step-by-step guide has you covered.