This repository contains the a basic Solana program made using the Anchor Framework. The code contains all the necessary workflow to develop a Solana Program, from development, deployment, to testing.
This project assumes your local machine have Node and Cargo installed.
MacOS & Linux
sh -c "$(curl -sSfL https://release.solana.com/v1.9.5/install)"Windows
curl https://release.solana.com/v1.9.5/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirsnpm i -g @project-serum/anchor-cliFor this tutorial, we're going to use a Filesystem wallet. This is sufficient for testing, but not recommended for production purpose.
solana-keygen new --no-outfileOpen lib.rs and edit the file to your needs. After completing the program, compile it to produce IDL.
anchor buildOnce the IDL is generated, get the program id.
solana address -k target/deploy/hello_anchor-keypair.jsonAfter the program id is generated, open Anchor.toml and add the following in it.
[programs.localnet]
hello_anchor = "program-id"
[programs.devnet]
hello_anchor = "program-id"
[programs.testnet]
hello_anchor = "program-id"To deploy the program to a chosen cluster,
anchor deploy --provider.cluster <cluster-name>where cluster-name could be localhost, testnet, devnet, and mainnet.
Once the program is deployed, you can test it with the following command.
anchor test