当前位置: 首页 > news >正文

solana 入门 1

solana-co-learn
Solana 开发学习笔记(一)——从 Hello World 出发

安装开发环境

windows下环境配置

wsl

First start with installing WSL on your system.

wsl --install
wsl

安装Ubuntu

列出可用的分发版

wsl.exe --list --online

显示:

以下是可安装的有效分发的列表。
使用 ‘wsl.exe --install ’ 安装。
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
Ubuntu-22.04 Ubuntu 22.04 LTS
OracleLinux_7_9 Oracle Linux 7.9
OracleLinux_8_7 Oracle Linux 8.7
OracleLinux_9_1 Oracle Linux 9.1
openSUSE-Leap-15.5 openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed openSUSE Tumbleweed

安装Ubuntu-22.04

wsl.exe --install Ubuntu-22.04

如果报错:

正在安装: Ubuntu 22.04 LTS 已安装 Ubuntu 22.04 LTS。 正在启动 Ubuntu 22.04 LTS…
Installing, this may take a few minutes… WslRegisterDistribution
failed with error: 0x80370102 Please enable the Virtual Machine
Platform Windows feature and ensure virtualization is enabled in the
BIOS. For information please visit https://aka.ms/enablevirtualization
Press any key to continue…

启用 Virtual Machine Platform Windows 功能:

打开“控制面板” -> “程序” -> “启用或关闭 Windows 功能”。
在弹出的窗口中找到“Virtual Machine Platform”复选框并勾选它。
单击“确定”并等待 Windows 完成更改。
确保 BIOS 中启用了虚拟化功能:
开机按F2,进入BIOS,找到【configuration】选项卡,【Inter Virtual Technology】,回车选择enable

参考:
https://zhuanlan.zhihu.com/p/586751199
https://zhuanlan.zhihu.com/p/617468891

我的电脑是 按F12 + Fn 进入dios界面

rust

Using the following command, we can install and configure the Rust tooling on your local system. The following command will automatically download the correct binaries needed for your specific operating system:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

As part of this Rust installer, Rustup will also configure your terminal’s PATH to include the rust toolchain.

After the installation is complete, restart your terminal or run the following command to manually refresh your new PATH settings to make the rust tooling (like cargo) available:

source ~/.bashrc

验证安装:

rustc --version

返回rustc 1.76.0 (07dca489a 2024-02-04)

Install the Solana CLI

本文带你轻松搭建solana验证节点

  1. 下载solana二进制文件
wget https://github.com/solana-labs/solana/releases/download/v1.17.24/solana-release-x86_64-unknown-linux-gnu.tar.bz2
  1. 解压solana二进制文件压缩包

    安装工具

    sudo apt update
    sudo apt install bzip2
    

    解压solana二进制文件压缩包

tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2
  1. 设置环境变量
cd solana-release/
export PATH=$PWD/bin:$PATH
  1. 查看当前已安装的solana版本
    显示有版本信息则安装成功
solana --version

踩坑指南:

官网下载命令根本不行

 sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

设置了中断代理也不行(我用的clash)

set http_proxy=http://127.0.0.1:7890 & set https_proxy=http://127.0.0.1:7890

只好在windows上下载solana-release-x86_64-unknown-linux-gnu.tar.bz2,下载链接 https://github.com/solana-labs/solana/releases/download/v1.17.24/solana-release-x86_64-unknown-linux-gnu.tar.bz2

从windows上复制到wsl上,参考https://blog.csdn.net/Caoyang_He/article/details/107898883

比如,我的文件放在D盘
在ubuntu终端输入:
cd /mnt/d
ls

就可以看到自己文件:
在这里插入图片描述
使用mv命令复制到目标文件夹

Install Anchor for Solana

  1. Install avm

    cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
    

    ps 上面的命令我也不行
    分解为:

    git clone https://github.com/coral-xyz/anchor.git
    cargo install --path=./anchor avm --locked --force
    

    报错:error: linker cc not found

    解决:

    sudo apt update
    sudo apt install build-essential
    
  2. Install Anchor using avm #
    To install the latest version of anchor using avm:

    avm install latest
    avm use latest
    

    坑:经常报错。解决方案换节点
    warning: be sure to add /home/ysh1/.avm/bin to your PATH to be able to run the installed binaries
    Now using anchor version 0.29.0.

    解决方案: export PATH=/home/ysh1/.avm/bin:$PATH

  3. checking
    After the anchor installation is complete, you can verify anchor was installed by checking the installed version:

    anchor --version
    

    上面的命令没用是因为path没有配好:

    要使用vi编辑.bashrc文件,您可以按照以下步骤进行:

    1. 打开终端
    2. 输入以下命令以使用vi编辑器打开.bashrc文件:
      vi .bashrc
      
    3. 您将看到.bashrc文件的内容以及vi编辑器的界面。
    4. 您可以使用vi编辑器的命令来编辑文件,例如:
      • i 进入插入模式,可以开始编辑文件
      • 编辑完成后,按 Esc 键退出插入模式
      • 输入 :wq 并按 Enter 保存并退出文件

    通过这些步骤,您可以使用vi编辑器来编辑.bashrc文件。请注意,vi编辑器可能对初学者来说有一定的学习曲线,您可以随时查阅vi编辑器的相关教程来了解更多操作方法。

    export PATH=/home/ysh1/solana/solana-release/bin:$PATH
    export PATH=/home/ysh1/.avm/bin:$PATH
    

source ~/.bashrc

相关文章:

  • AJAX 03 XMLHttpRequest、Promise、封装简易版 axios
  • WPS 相较于其他办公软件有哪些优势?
  • 【Node.js从基础到高级运用】十二、身份验证与授权:JWT
  • 操作系统(多线程)
  • 基于单片机的车载酒精含量自检系统设计与实现
  • Selenium 学习(0.20)——软件测试之单元测试
  • 综合知识篇02-UML统一建模语言(2024年软考高级系统架构设计师冲刺知识点总结系列文章)
  • ChatGPT-Next-Web SSRF漏洞+XSS漏洞复现(CVE-2023-49785)
  • UE4案例记录
  • 二 centos 7.9 磁盘挂载
  • Unreal发布Android在刘海屏手机上不能全屏显示问题
  • CompletableFuture原理与实践-外卖商家端API的异步化
  • 爬虫3_爬取翻页URL不变的网站
  • ETAS工程在ISOLA软件中如何看到OS中断的配置
  • bootstrap企业网站前端模板
  • 【347天】每日项目总结系列085(2018.01.18)
  • dva中组件的懒加载
  • JavaScript设计模式系列一:工厂模式
  • Just for fun——迅速写完快速排序
  • opencv python Meanshift 和 Camshift
  • seaborn 安装成功 + ImportError: DLL load failed: 找不到指定的模块 问题解决
  • ⭐ Unity 开发bug —— 打包后shader失效或者bug (我这里用Shader做两张图片的合并发现了问题)
  • Vim Clutch | 面向脚踏板编程……
  • WebSocket使用
  • windows-nginx-https-本地配置
  • 动态规划入门(以爬楼梯为例)
  • 官方解决所有 npm 全局安装权限问题
  • 解析带emoji和链接的聊天系统消息
  • 首页查询功能的一次实现过程
  • 为物联网而生:高性能时间序列数据库HiTSDB商业化首发!
  • 项目管理碎碎念系列之一:干系人管理
  • 你对linux中grep命令知道多少?
  • NLPIR智能语义技术让大数据挖掘更简单
  • ​ssh-keyscan命令--Linux命令应用大词典729个命令解读
  • # 再次尝试 连接失败_无线WiFi无法连接到网络怎么办【解决方法】
  • ( 10 )MySQL中的外键
  • (附源码)spring boot基于Java的电影院售票与管理系统毕业设计 011449
  • (附源码)计算机毕业设计ssm-Java网名推荐系统
  • (论文阅读23/100)Hierarchical Convolutional Features for Visual Tracking
  • (全注解开发)学习Spring-MVC的第三天
  • (转)机器学习的数学基础(1)--Dirichlet分布
  • (轉貼)《OOD启思录》:61条面向对象设计的经验原则 (OO)
  • .NET DataGridView数据绑定说明
  • .NET MVC 验证码
  • .NET 依赖注入和配置系统
  • .NET 中让 Task 支持带超时的异步等待
  • .NET/C# 使用 #if 和 Conditional 特性来按条件编译代码的不同原理和适用场景
  • .NET使用存储过程实现对数据库的增删改查
  • 。Net下Windows服务程序开发疑惑
  • [Android] Upload package to device fails #2720
  • [AUTOSAR][诊断管理][ECU][$37] 请求退出传输。终止数据传输的(上传/下载)
  • [C# 基础知识系列]专题十六:Linq介绍
  • [CDOJ 838]母仪天下 【线段树手速练习 15分钟内敲完算合格】
  • [CSS]中子元素在父元素中居中
  • [EFI]DELL XPS13 9360电脑 Hackintosh 黑苹果efi引导文件