新一代公链代表Solana(5) --- 如何通过命令行安装Solana本地钱包

本文详细介绍了如何在Mac上安装和配置Solana的命令行工具,包括设置网络环境、生成新账户、查看余额以及转账操作,还提到通过第三方水龙头获取测试代币的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前文演示的是第三方钱包的使用 Solana的第三方钱包使用

Solana官方为我们提供了一套命令行工具来实现对Solana的操作,支持Mac/Linux/Windows,下面我们以Mac作为演示平台进行操作。

安装

luca@LucadeMacBook-Air ~ % sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
downloading stable installer
  ✨ stable commit d0ed878 initialized
Adding 
export PATH="/Users/luca/.local/share/solana/install/active_release/bin:$PATH" to /Users/luca/.profile
Adding 
export PATH="/Users/luca/.local/share/solana/install/active_release/bin:$PATH" to /Users/luca/.zprofile
Adding 
export PATH="/Users/luca/.local/share/solana/install/active_release/bin:$PATH" to /Users/luca/.bash_profile

Close and reopen your terminal to apply the PATH changes or run the following in your existing shell:
  
export PATH="/Users/luca/.local/share/solana/install/active_release/bin:$PATH"

按照提示设置好Path,验证是否安装成功

luca@LucadeMacBook-Air ~ % export PATH="/Users/luca/.local/share/solana/install/active_release/bin:$PATH"
luca@LucadeMacBook-Air ~ % 
luca@LucadeMacBook-Air ~ % 
luca@LucadeMacBook-Air ~ % solana --version
solana-cli 1.17.25 (src:d0ed878d; feat:3580551090, client:SolanaLabs)

设置网络环境

Solana的网络生态划分为开发网devnet、测试网testnnet和主网mainnet三个主要环境。开发网专为Solana节点的开发者设计,更新频繁,旨在提供最新的功能和技术支持。测试网则为DApp开发者提供一个相对稳定的环境,用于测试他们的应用程序。而主网则是正式环境,其中的代币具有真实的价值。

在开发网上,开发者可以申请空投的测试代币,以便进行开发和测试。

这里我们选取的是测试网testnet

luca@LucadeMacBook-Air ~ % solana config set --url https://api.testnet.solana.com

Config File: /Users/luca/.config/solana/cli/config.yml
RPC URL: https://api.testnet.solana.com 
WebSocket URL: wss://api.testnet.solana.com/ (computed)
Keypair Path: /Users/luca/.config/solana/id.json 
Commitment: confirmed

新建账户

luca@LucadeMacBook-Air ~ % solana-keygen new --force

Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none): 
Enter same passphrase again: 

Wrote new keypair to /Users/luca/.config/solana/id.json
======================================================================
pubkey: E3NAyseUZrgwSbYe2g47TuFJr5CxAeneK63mR4Ufbqhh
======================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
juice vocal head squirrel minor scene nasty sweet arena best pear cave
======================================================================

设定好助记词(助记词可用来恢复账号),keypair被加密存在"/Users/you/.config/solana/id.json"。

其中pubkey就是你的钱包地址,也可以通过如下命令可以查看当前账号的地址,也就是上面的Keypair文件的中的公钥

luca@LucadeMacBook-Air ~ % solana-keygen pubkey

E3NAyseUZrgwSbYe2g47TuFJr5CxAeneK63mR4Ufbqhh

查看账户余额

luca@LucadeMacBook-Air ~ % solana balance
0 SOL

申请水龙头

现在直接通过命令行领会失败

luca@LucadeMacBook-Air ~ % solana airdrop 1
Requesting airdrop of 1 SOL
Error: unable to confirm transaction. This can happen in situations such as transaction expiration and insufficient fee-payer funds

这里我们选择第三方水龙头网站来领取 faucet

在这里插入图片描述

再次查询余额

luca@LucadeMacBook-Air ~ % solana balance
1 SOL

链上查看
在这里插入图片描述

转账

luca@LucadeMacBook-Air ~ % solana transfer 6nmqFHKGZP8AXpdh3ynwV4GQS1cc64wG8e8dZUgX4RoM 0.1

Signature: 5ogR3R3qjkamiGTEP9jnoBZ9vJirjMHm93fXCmkpGDnsuvz1XBibYaojrPnww4ob4LXpqdTgzhSogEFMHhxQisft

查看余额

luca@LucadeMacBook-Air ~ % solana balance                                                  
0.899995 SOL

浏览器查看
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Lucarun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值