工具教学
小于 1 分钟
工具教学
开发工具
安装Rust
安装Solana
sh -c "$(curl -sSfL https://release.solana.com/v1.18.18/install)"
- 安装Anchor
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev libssl-dev
avm install latest
avm use latest
awesome-solana
HelloWorld
- anchor init test1
- anchor build
use anchor_lang::prelude::*;
declare_id!("BgfQ9VDxpZGW3WWj4ZW4hwSxSf8W63jZB7HdVvmttW48");
#[program]
pub mod test1 {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
msg!("Greetings from: {:?}", ctx.program_id);
Ok(())
}
}
#[derive(Accounts)]
pub struct Initialize {}
- anchor deploy
命令行
Command | Command | Command | Command |
---|---|---|---|
solana | solana-genesis | solana-keygen | solana-stake-accounts |
solana-watchtower | solana-bench-tps | solana-gossip | solana-ledger-tool |
solana-test-validator | solana-dos | solana-install | solana-log-analyzer |
solana-tokens | solana-faucet | solana-install-init | solana-net-shaper |
solana-validator |
Solana命令行
- solana-keygen new 生成密钥对
~/.config/solana/id.json
[105,38,176,206,95,148,97,25,221,92,90,24,179,189,244,158,81,171,136,91,73,10,162,176,222,236,38,165,158,111,210,51,235,185,88,38,143,151,5,157,103,104,148,124,47,142,116,104,230,241,34,218,162,254,236,160,97,136,225,209,215,218,163,144]
- solana-keygen pubkey 查看公钥
solana-keygen pubkey ~/.config/solana/id.json
GsAjFVdC3PXReBrgnTw22edFoVmJjaWPEjTjXznsBDfu
- solana-keygen verify 校验密钥对
solana-keygen verify GsAjFVdC3PXReBrgnTw22edFoVmJjaWPEjTjXznsBDfu
- solana-keygen recover 'prompt://' 助记词恢复
符合BIP-39格式
abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
solana balance 查看余额
切换网络地址
solana config set --url https://api.devnet.solana.com
solana config set --url https://api.testnet.solana.com
solana config set --url https://api.mainnet-beta.solana.com