-
Local developing on Solana means you will set up a local validator so that programs can be tested before being deployed to the blockchain.
-
In each environment, you will be using one of three networks:
- Mainnet: the production network where all the action happens. Transactions cost real money.
- Testnet: used for stress testing recent releases. Focused on network performance, stability, and validator behavior.
- Devnet: the primary network for development (these tokens have no financial value).
-
Set up the development environment with a local blockchain cluster.
-
Create a filesystem wallet and airdrop Solana tokens to it.
-
Write programs.
- Programs export a known
entrypoint
symbol which the Solana runtime looks up and calls when invoking a program.
- Programs export a known
-
Compile the program (down to Berkley Packet Filter byte-code that will then be deployed to the blockchain).
-
Generate the program's public address (a new unique keypair, on which the pubkey is the
program_id
). -
Deploy the program to the selected blockchain cluster by creating transactions containing the program's byte-code.
-
Once the entire program is in the blockchain, a final transaction is sent to write all of the buffered byte-code to the program's data account.
- This either marks the new program as executable or completes upgrading an existing program.
-
Install
solana-cli
using these instructions. This will provide commands for:- creating and managing file-system Solana wallets/keypairs
- connecting to Solana clusters
- building Solana programs
- deploying your programs to the blockchain
-
Install the Anchor framework using these instructions.
- You can run a full blockchain cluster on your machine and configure solana-cli to use it with these commands:
solana-test-validator
solana config set --url localhost
-
To deploy a program with Solana CLI, you need a Solana wallet with SOL tokens.
-
To create a simple file system wallet (at
~/.config/solana/id.json
) to use during local developments, type:
solana-keygen new
- You can set your new wallet as the default:
solana config get -k ~/.config/solana/id.json
- Aidrop testing Solana tokens:
solana airdrop 10
solana balance
-
The Solana blockchain has several different groups of validators, known as Clusters.
-
Each serves different purposes within the ecosystem and contains dedicated API nodes to fulfill JSON-RPC requests.
-
The individual nodes within a Cluster are owned and operated by third parties, and each has a public endpoint.
-
The Solana Labs organization operates a public RPC endpoint for each Cluster. Each of these public endpoints is subject to rate limits.
-
You can check your local config with:
solana config get
Config File: ~/.config/solana/cli/config.yml
RPC URL: http://localhost:8899
WebSocket URL: ws://localhost:8900/ (computed)
Keypair Path: ~/.config/solana/id.json
Commitment: confirmed
-
Devnet serves as a playground for devs.
-
Gossip endpoint at
entrypoint.devnet.solana.com:8001
. -
Devnet endpoint:
https://api.devnet.solana.com
. -
From the CLI, one can connect with:
solana config set --url https://api.devnet.solana.com
-
Testnet serves as Solana's core contributors stress test.
-
Gossip endpoint at
entrypoint.testnet.solana.com:8001
. -
Devnet endpoint:
https://api.testnet.solana.com
. -
From the CLI, one can connect with:
solana config set --url https://api.testnet.solana.com
-
Solana's permissionless, persistent cluster.
-
Gossip endpoint at
entrypoint.mainnet-beta.solana.com:8001
. -
Devnet endpoint:
https://api.mainnet-beta.solana.com
. -
From the CLI, one can connect with:
solana config set --url https://api.mainnet-beta.solana.com
- Test your setup by running this demo.
- Test your learnings by running this demo.
- Showing a program account:
solana program show <ACCOUNT_ADDRESS>
- Getting information about any transaction:
solana confirm -v <TRANSACTION_HASH>
- Getting the public key:
solana-keygen pubkey
- Redeploy a Solana Program:
solana program deploy <PROGRAM_FILEPATH>
- If a program has been deployed, and redeployment goes beyond the
max_len
of the account, it's possible to extend the program to fit the larger redeployment:
solana program extend <PROGRAM_ID> <ADDITIONAL_BYTES>
-
@solana/web3.js: a library with many basic Solana tools to interact, send transactions, and read from the blockchain.
-
@solana/spl-token: a library that contains many of the js/ts bindings needed to interact with SPL tokens. You can use this library to mint new tokens, transfer tokens, etc.
-
wallet-adapter: is a collection of libraries that help bootstrap wallet collections within Solana (such as Phantom, Solflare, and more).
-
VSCode's rust analyzer: support for the Rust such as code completion, references, workspace symbol search, semantic syntax highlighting, etc.
-
Seahorse's examples: Seahorse's compiler generates intermediate Rust artifacts and uses Anchor for the heavy lifting.