首页 > 其他分享 >Solana 开发学习之Solana 基础知识

Solana 开发学习之Solana 基础知识

时间:2024-02-21 15:48:55浏览次数:25  
标签:qiaopengjun -- Solana 基础知识 学习 devnet https com solana

Solana 开发学习之Solana 基础知识

Install the Solana CLI

相关链接

实操

  • 安装
sh -c "$(curl -sSfL https://release.solana.com/v1.18.2/install)"

downloading v1.18.2 installer
  ✨ 1.18.2 initialized
Adding
export PATH="/Users/qiaopengjun/.local/share/solana/install/active_release/bin:$PATH" to /Users/qiaopengjun/.profile
Adding
export PATH="/Users/qiaopengjun/.local/share/solana/install/active_release/bin:$PATH" to /Users/qiaopengjun/.zprofile
Adding
export PATH="/Users/qiaopengjun/.local/share/solana/install/active_release/bin:$PATH" to /Users/qiaopengjun/.bash_profile

Close and reopen your terminal to apply the PATH changes or run the following in your existing shell:

export PATH="/Users/qiaopengjun/.local/share/solana/install/active_release/bin:$PATH"

  • 配置环境变量
vim .zshrc

# 复制并粘贴下面命令以更新 PATH
export PATH="/Users/qiaopengjun/.local/share/solana/install/active_release/bin:$PATH"
  • 通过运行以下命令确认您已安装了所需的 Solana 版本:
solana --version

# 实操
solana --version
solana-cli 1.18.2 (src:13656e30; feat:3352961542, client:SolanaLabs)
  • 切换版本
solana-install init 1.16.4

设置网络环境

官方RPC地址分别是:

相关链接

实操

solana config set --url https://api.devnet.solana.com

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

创建账号

相关链接

Check your installation

运行以下命令检查 solana-keygen 是否安装正确:

solana-keygen --version

# 实操
solana-keygen --version
solana-keygen 1.18.2 (src:13656e30; feat:3352961542, client:SolanaLabs)

使用 solana-keygen 工具,可以生成新的种子短语,以及从现有的种子短语和(可选的)密码短语派生一个密钥对。

种子短语和口令短语可以作为纸钱包一起使用。只要您保持您的种子短语和密码存储安全,您可以使用它们访问您的帐户。

For full usage details, run:

solana-keygen new --help

solana-keygen-new
Generate new keypair file from a random seed phrase and optional BIP39 passphrase

USAGE:
    solana-keygen new [OPTIONS]

OPTIONS:
    -C, --config <FILEPATH>
            Configuration file to use [default: /Users/qiaopengjun/.config/solana/cli/config.yml]

        --derivation-path [<DERIVATION_PATH>...]
            Derivation path. All indexes will be promoted to hardened. If arg is not presented then
            derivation path will not be used. If arg is presented with empty DERIVATION_PATH value
            then m/44'/501'/0'/0' will be used.

    -f, --force
            Overwrite the output file if it exists

    -h, --help
            Print help information

        --language <LANGUAGE>
            Specify the mnemonic language that will be present in the generated seed phrase
            [default: english] [possible values: english, chinese-simplified, chinese-traditional,
            japanese, spanish, korean, french, italian]

        --no-bip39-passphrase
            Do not prompt for a BIP39 passphrase

        --no-outfile
            Only print a seed phrase and pubkey. Do not output a keypair file

    -o, --outfile <FILEPATH>
            Path to generated file

    -s, --silent
            Do not display seed phrase. Useful when piping output to other programs that prompt for
            user input, like gpg

        --word-count <NUMBER>
            Specify the number of words that will be present in the generated seed phrase [default:
            12] [possible values: 12, 15, 18, 21, 24]

实操

sosolana-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):

Wrote new keypair to /Users/qiaopengjun/.config/solana/id.json
=================================================================================
pubkey: 账号的地址
=================================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
对应的BIP39的助记词
=================================================================================

查看当前账号的地址,Keypair文件的中的公钥:

solana-keygen pubkey

申请水龙头

solana airdrop 1

Requesting airdrop of 1 SOL

Signature: GTVSLYa9Vm1FfjBSDVxf8cBL6D47caXHuETRbdD3eQ5C36ZA261MLJXBxzWU2HoiaedAAmBdiy17YFnSaiWsvW3

1 SOL

Solana CLI Reference and Usage

查看当前账号的余额

solana balance
1 SOL

查看 config

cat .config/solana/cli/config.yml
---
json_rpc_url: https://api.devnet.solana.com
websocket_url: ''
keypair_path: /Users/qiaopengjun/.config/solana/id.json
address_labels:
  '11111111111111111111111111111111': System Program
commitment: confirmed

转账

solana transfer --allow-unfunded-recipient H6Su7YsGK5mMASrZvJ51nt7oBzD88V8FKSBPNnRG1u3k 0.01

Signature: 5t9ysYELu2Gv1jc7SDXzmZotLUDhkUwuSd48tH2QSqJy8iTYkXD7Sf9fNVxXhkcUZsCy7s7WvsddRbxrfK3tKmEg

练习

通过命令行,发行一个代币。并给自己账号mint一定数量的代币。 并通过插件钱包或者命令行的方式给其他同学空投该代币

  1. 设置环境为开发环境

  2. 创建账号

  3. 申请水龙头

  4. 创建Token

spl-token create-token
Creating token E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

Address:  E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx
Decimals:  9

Signature: 51yuJ91agCKxYWEbLgMfEq5BWBTaFZoezxfnKVoTmrGi59S44q7nKkfVjsCpMJNVLwW8AKuiNbNKb4JSUzLHQy9d

  1. 创建Token Account
spl-token create-account E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx
Creating account HDv1RgdHjrjSdnTFJsMqQGPcKTiuF7zLjhNaSd7ihbKh

Signature: 3shwWeUAiFYTE2qfARofhyPRtHvtGBRNf2oB8AoxsAX11mEbUsxk2q35YSmWBcBQEnhS2t2LsBnQ9bjt4m2WR3qt

  1. Token Account Mint
spl-token mint E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx 100 HDv1RgdHjrjSdnTFJsMqQGPcKTiuF7zLjhNaSd7ihbKh
Minting 100 tokens
  Token: E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx
  Recipient: HDv1RgdHjrjSdnTFJsMqQGPcKTiuF7zLjhNaSd7ihbKh

Signature: 4XdNt4yotJdcKN1JGSqm4CL8tQ8vELzGLNGT8ChucQWmofSBpSz2jU8gHmET18PBu2Z3ZGt9RkzRAwuZ5DdBEzba

  1. 查询余额
spl-token balance E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx
100
  1. 转账
spl-token transfer --fund-recipient E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx 10 H6Su7YsGK5mMASrZvJ51nt7oBzD88V8FKSBPNnRG1u3k
Transfer 10 tokens
  Sender: HDv1RgdHjrjSdnTFJsMqQGPcKTiuF7zLjhNaSd7ihbKh
  Recipient: H6Su7YsGK5mMASrZvJ51nt7oBzD88V8FKSBPNnRG1u3k
  Recipient associated token account: HY1GfCQabyUMFRGpDu3eFoVW3ny8ifHKVZ8LbvzbDPsK
  Funding recipient: HY1GfCQabyUMFRGpDu3eFoVW3ny8ifHKVZ8LbvzbDPsK

Signature: 4jbcoJYS6ZGPcUmHpqTnxeLHfQxvUqQQnzgoJCgWWA1LpKkKWRA5y2FZ7rDQ2v4NBBcuUJqh37A9p92mvbTmS6iY

  1. 查询余额
spl-token balance E7eHC3g4QsFXuaBe3X2wVr54yEvHK8K8fq6qrgB64djx
90

标签:qiaopengjun,--,Solana,基础知识,学习,devnet,https,com,solana
From: https://www.cnblogs.com/QiaoPengjun/p/18025318

相关文章

  • TS学习随笔
    1,ts是什么TypeScript是JavaScript的超集,这意味着它可以完成JavaScript所做的所有事情,而且额外附带了一些能力。TypedJavaScriptatAnyScale.它强调了TypeScript的两个最重要的特性——类型系统、适用于任何规模。 JavaScript本身是一种动态类型语言,这意味着变量可......
  • Vue 学习笔记 3--live server
    liveserver插件在Vscode扩展插件中安装liveserver,启用扩展后展示如下所示: 单击GoLive,会运行启用网页,如下图所示: 注:使用http://127.0.0.1:5500/可查看网页下详细资源信息 ......
  • Python 机器学习工具 scikit-learn 的入门使用
    参考文档:https://www.scikitlearn.com.cn/通过对已有多组数据的训练,从而实现对单个数据的结果预测安装pipinstall-Uscikit-learnDemo通过使用sklearn包中的决策树DecisionTreeclassifier算法实现简单预测importsklearnfromsklearnimporttreefeature=[[178,1],......
  • 全流程点云机器学习(二)使用PaddlePaddle进行PointNet的机器学习训练和评估
    前言这不是高支模项目需要嘛,他们用传统算法切那个横杆竖杆流程复杂耗时很长,所以想能不能用机器学习完成这些工作,所以我就来整这个工作了。基于上文的数据集切分,现在来对切分好的数据来进行正式的训练。本系列文章所用的核心骨干网络代码主要来自点云处理:实现PointNet点云分割......
  • 深度学习在时间序列预测的总结和未来方向分析
    2023年是大语言模型和稳定扩散的一年,时间序列领域虽然没有那么大的成就,但是却有缓慢而稳定的进展。Neurips、ICML和AAAI等会议都有transformer结构(BasisFormer、Crossformer、Invertedtransformer和Patchtransformer)的改进,还出现了将数值时间序列数据与文本和图像合成的新体......
  • Vue 学习笔记2 -- 开发环境
    第一步:创建文件夹并在VScode中打开第二步:创建src目录+index.html第三步:https://v2.cn.vuejs.org/v2/guide/installation.html下载vue依赖文件,如下图所示: 第四步:引入vue.js,如下图所示: 第五步:运行+F12解决如下图问题 https://v2.cn.vuejs.org/v2/guide/instal......
  • 学习链接
    负载调整率(为什么调高增益有利于)https://blog.csdn.net/gonylibechen1/article/details/134589961电源抑制比(为什么调高增益有利于)https://zhuanlan.zhihu.com/p/652476773电源抑制比代表了输入电压变化与输出电压的变化的比率,其参数可以表示如下公式:PSRR=20LgΔVIN/ΔVo对......
  • Linux 网络编程从入门到进阶 学习指南
    前言大家好,我是小康。在上一篇文章中,我们探讨了Linux系统编程的诸多基础构件,包括文件操作、进程管理和线程同步等,接下来,我们将视野扩展到网络世界。在这个新篇章里,我们要让应用跳出单机限制,学会在网络上跨机器交流信息。接下来,我们要深入套接字(sockets)和TCP/IP协议,揭示如何......
  • Linux 系统编程从入门到进阶 学习指南
    引言大家好,我是小康,今天我们来学习一下Linux系统编程相关的知识。Linux系统编程是连接高级语言和硬件的桥梁,它对深入理解计算机系统至关重要。无论你是打算构建高性能服务器还是开发嵌入式设备,掌握Linux系统编程是C和C++开发者的基本技能。本文旨在为初学者提供一个清......
  • 【深度学习】TensorFlow实现线性回归,代码演示。全md文档笔记(代码文档已分享)
    本系列文章md笔记(已分享)主要讨论深度学习相关知识。可以让大家熟练掌握机器学习基础,如分类、回归(含代码),熟练掌握numpy,pandas,sklearn等框架使用。在算法上,掌握神经网络的数学原理,手动实现简单的神经网络结构,在应用上熟练掌握TensorFlow框架使用,掌握神经网络图像相关案例。具体......