- 安装Solana客户端 详细安装文档: https://docs.solanalabs.com/cli/install
sh -c "$(curl -sSfL https://release.solana.com/v1.18.4/install)"
solana --version
- 安装Rust https://rustup.rs/
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- 安装SPL客户端
cargo install spl-token-cli
- 配置RPC节点
- 查询当前配置
$ solana config get
Config File: ${HOME}/.config/solana/cli/config.yml
RPC URL: https://api.mainnet-beta.solana.com
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
Keypair Path: ${HOME}/.config/solana/id.json
- 设置RPC节点地址
solana config set --url https://api.devnet.solana.com
- 克隆教学仓库
git clone https://github.com/Fankouzu/solana-basic.git
npm install
- JS
npm run demo scripts/1.Keypair.ts
- CLI
solana-keygen pubkey
npm run demo scripts/2.LuckyAccount.ts
npm run demo scripts/3.Payer.ts
./scripts/4.MinimumBalanceForRentExemption.ts
./scripts/5.CreateAccountIx.ts
./scripts/7.CreateVersionedTx.ts
npm run demo scripts/10.SendSimpleTx.ts
npm run demo scripts/11.SendComplexTx.ts
npm run demo scripts/12.CreateMint.ts
npm run demo scripts/14.MintTokens.ts
- 创建Token
spl-token create-token
- 查询总量
spl-token supply AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
- 创建账户
spl-token create-account AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
- 查询余额
spl-token balance AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM
- 铸造Token
spl-token mint AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 100
npm run demo scripts/15.GetTokenAccountsByOwner.ts