Build & Deploy Your First Program
This guide provides a step-by-step overview of deploying a program on BARA SVM. Familiarity with command-line tools is necessary.
1. Install CLI Tools
Ensure that the Solana command line tools are installed as you will be using these tools throughout the deployment process.
2. Write Your Program
Develop your program logic. For those using Rust with Anchor, input your program logic into the lib.rs file located in the src directory of your project. Confirm that your program compiles correctly and passes all tests.
3. Build Your Program
Compile your program to a BPF (Berkeley Packet Filter) executable, the format required for on-chain programs:
With Anchor
Run anchor build. Anchor manages the compilation details.
Without Anchor
Use cargo build-bpf for direct Rust usage.
4. Deploy Your Program
Before deploying your program, ensure your CLI is set to the BARA Devnet network using the following command:
After deploying your building your program and configuring your RPC URL, you can deploy your program with the following command:
Ensure that you have enough SOL in your wallet to cover deployment costs. You can get some devnet tokens from the BARA faucet.
After configuring your network, you may now deploy your program to BARA. Use the following commands based on your setup:
With Anchor
If the Anchor CLI is installed, you can deploy your program with the following command. This handles the deployment automatically.
Without Anchor
If you're using the native solana method to author your program, you can also use the Solana CLI to deploy your program.
5. Verify Deployment
Post-deployment, check that your program operates as intended. Interact with your program using Solana's web3.js library or the CLI tools to send transactions.
Additional Tips:
Keep your program's keypair secure for future upgrades or interactions.
Monitor the network and your program's performance, particularly if it gains widespread usage.
Example: "Hello BARA!" Program
This example implements a simple Greeting Counter Program on BARA.
With Solana Native Program
With Anchor Program
If you are building with Anchor, you may use the variant below. Please remember to change the program ID after building your program with anchor build before deploying it.
Run your dAPP on BARA Devnet
Example "Hello World" application in TypeScript:
With Solana Native Program dApp
With Anchor Program dApp
Running the above script [either with Solana Native, or with Anchor] programs should output the following:
You can find an example of the executed transaction here. The program address for this program is here.
Last updated