From 9ce5dfcb5d00fdf3097b35f6a08587713d2487a0 Mon Sep 17 00:00:00 2001 From: Derick Date: Mon, 3 Jun 2024 23:29:20 +0800 Subject: [PATCH 1/5] programs-examples translate --- docs/SolanaDocumention/programs/examples.md | 103 ++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/docs/SolanaDocumention/programs/examples.md b/docs/SolanaDocumention/programs/examples.md index e69de29..87d2883 100644 --- a/docs/SolanaDocumention/programs/examples.md +++ b/docs/SolanaDocumention/programs/examples.md @@ -0,0 +1,103 @@ +# 程序示例 + + +"[Solana程序示例](https://github.com/solana-developers/program-examples)" GitHub仓库提供了多个子文件夹,每个文件夹包含不同Solana编程范式和语言的代码示例,旨在帮助开发者学习和实验Solana区块链开发。 + +你可以在`solana-developers/program-examples`中找到这些示例以及README文件,这些文件会解释如何运行不同的示例。大多数示例是自包含的,并且有原生Rust(即无框架)、[Anchor](https://www.anchor-lang.com/docs/installation)、[Seahorse](https://seahorse-lang.org/)的版本,还包含我们希望[看到的贡献示例](https://github.com/solana-developers/program-examples?tab=readme-ov-file#examples-wed-love-to-see)。 +在仓库中,你会找到以下子文件夹,每个文件夹内有各种示例程序: + +- [程序示例](#程序示例) + - [基础](#基础) + - [压缩](#压缩) + - [预言机](#预言机) + - [代币](#代币) + - [Token 2022(代币扩展)](#token-2022代币扩展) + - [Break](#break) + - [构建和运行](#构建和运行) + +## 基础 + +包含一系列示例,展示了使用原生Rust库构建Solana程序的基础步骤。这些示例旨在帮助开发者理解Solana编程的核心概念。 + +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------- | +| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/account-data) | 在账户中保存地址、姓名、门牌号、街道和城市。 | 原生, Anchor | +| [检查账户](https://github.com/solana-developers/program-examples/tree/main/basics/checking-accounts) | 安全课程,展示如何进行账户检查。 | 原生, Anchor | +| [关闭账户](https://github.com/solana-developers/program-examples/tree/main/basics/close-account) | 展示如何关闭账户以取回租金。 | 原生, Anchor | +| [计数器](https://github.com/solana-developers/program-examples/tree/main/basics/counter) | 一个简单的计数器程序,包含所有不同的架构。 | 原生, Anchor, Seahorse, mpl-stack | +| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/create-account) | 如何在程序中创建系统账户。 | 原生, Anchor | +| [跨程序调用](https://github.com/solana-developers/program-examples/tree/main/basics/cross-program-invocation) | 使用手和杠杆的类比展示如何在程序中调用另一个程序。 | 原生, Anchor | +| [你好Solana](https://github.com/solana-developers/program-examples/tree/main/basics/hello-solana) | Hello world示例,仅在交易日志中打印hello world。 | 原生, Anchor | +| [PDA租金支付者](https://github.com/solana-developers/program-examples/tree/main/basics/pda-rent-payer) | 展示如何使用PDA的lamports支付新账户的费用。 | 原生, Anchor | +| [处理指令](https://github.com/solana-developers/program-examples/tree/main/basics/processing-instructions) | 展示如何处理指令数据字符串和u32。 | 原生, Anchor | +| [程序派生地址](https://github.com/solana-developers/program-examples/tree/main/basics/program-derived-addresses) | 展示如何使用种子引用PDA并在其中保存数据。 | 原生, Anchor | +| [重新分配](https://github.com/solana-developers/program-examples/tree/main/basics/realloc) | 展示如何增加和减少现有账户的大小。 | 原生, Anchor | +| [租金](https://github.com/solana-developers/program-examples/tree/main/basics/rent) | 你将在这里学习如何在程序中计算租金要求。 | 原生, Anchor | +| [仓库布局](https://github.com/solana-developers/program-examples/tree/main/basics/repository-layout) | 关于如何构建程序布局的建议。 | 原生, Anchor | +| [转移SOL](https://github.com/solana-developers/program-examples/tree/main/basics/transfer-sol) | 展示系统账户和PDA的不同SOL转移方法。 | 原生, Anchor, Seahorse | + +## 压缩 + +包含一系列示例,展示如何在Solana上使用[状态压缩](/docs/advanced/state-compression.md)。主要集中在压缩NFT(cNFT)。 + +| 示例名称 | 描述 | 语言 | +| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------ | +| [cNFT销毁](https://github.com/solana-developers/program-examples/tree/main/compression/cnft-burn) | 要销毁cNFT,可以将其烧毁。此示例展示了如何在程序中执行此操作。 | Anchor | +| [cNFT保险库](https://github.com/solana-developers/program-examples/tree/main/compression/cnft-vault/anchor) | 如何在程序中保管cNFT并再次发送出去。 | Anchor | +| [cutils](https://github.com/solana-developers/program-examples/tree/main/compression/cutils) | 一套工具,例如在程序中铸造和验证cNFT。 | Anchor | + +## 预言机 + +预言机允许在程序中使用链下数据。 + +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------------------ | -------------------------------------------------------------------- | ---------------- | +| [Pyth](https://github.com/solana-developers/program-examples/tree/main/oracles/pyth) | Pyth使代币的价格数据在链上程序中可用。 | Anchor, Seahorse | + +## 代币 + +大多数Solana上的代币使用Solana程序库(SPL)代币标准。这里你可以找到许多关于如何铸造、转移、销毁代币以及如何在程序中与它们交互的示例。 + +| 示例名称 | 描述 | 语言 | +| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------ | +| [创建代币](https://github.com/solana-developers/program-examples/tree/main/tokens/create-token) | 如何创建代币并添加Metaplex元数据。 | Anchor, 原生 | +| [NFT铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/nft-minter) | 仅铸造一个代币数量,然后移除铸造权限。 | Anchor, 原生 | +| [PDA铸造权限](https://github.com/solana-developers/program-examples/tree/main/tokens/pda-mint-authority) | 展示如何更改铸造的铸造权限,以便在程序中铸造代币。 | Anchor, 原生 | +| [SPL代币铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/spl-token-minter) | 解释如何使用关联代币账户来跟踪代币账户。 | Anchor, 原生 | +| [代币交换](https://github.com/solana-developers/program-examples/tree/main/tokens/token-swap) | 广泛的示例,展示如何为SPL代币构建AMM(自动做市商)池。 | Anchor | +| [转移代币](https://github.com/solana-developers/program-examples/tree/main/tokens/transfer-tokens) | 展示如何使用CPI将SPL代币转移到代币程序中。 | Anchor, 原生, Seahorse | +| [Token-2022](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022) | 参见Token 2022(代币扩展)。 | Anchor, 原生 | + +## Token 2022(代币扩展) + +Token 2022是Solana上的新代币标准。它更灵活,允许你为代币铸造添加16种不同的扩展,以增加更多功能。完整的扩展列表可以在[入门指南](https://solana.com/developers/guides/token-extensions/getting-started)中找到。 + +| 示例名称 | 描述 | 语言 | +| ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ------ | +| [基础](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/basics/anchor) | 如何创建代币、铸造和转移它。 | Anchor | +| [默认账户状态](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/default-account-state/native) | 此扩展允许你创建具有特定状态的代币账户,例如冻结状态。 | 原生 | +| [铸造关闭权限](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/mint-close-authority) | 旧代币程序中无法关闭铸造,现在可以了。 | 原生 | +| [多重扩展](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/multiple-extensions) | 展示如何为单个铸造添加多个扩展。 | 原生 | +| [NFT元数据指针](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer) | 可以使用元数据扩展创建NFT并添加动态链上元数据。 | Anchor | +| [不可转移](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/non-transferable/native) | 例如用于成就、推荐计划或任何灵魂绑定代币。 | 原生 | +| [转移费用](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-fees) | 每次转移代币时,部分代币会保留在代币账户中,然后可以收集这些代币。 | 原生 | +| [转移钩子](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-hook) | 四个示例展示如何使用CPI从代币程序到你的程序中为代币添加额外功能。 | Anchor | + +## Break + +[Break](https://break.solana.com/)是一个React应用程序,给用户一种直观的感觉,展示Solana网络的快速和高性能。你能_打破_ Solana区块链吗?在15秒的游戏过程中,每次点击按钮或按键都会向集群发送一个新交易。尽可能快地敲击键盘,观看你的交易实时完成,而网络则从容应对! + +Break可以在我们的Devnet、Testnet和Mainnet Beta网络上玩。在Devnet和Testnet上游戏是免费的,游戏会由网络水龙头资助。在Mainnet Beta上,用户每局游戏需支付0.08 SOL。会话账户可以通过本地密钥库钱包资助,或通过扫描Trust Wallet的二维码转移代币。 + +[点击这里玩Break](https://break.solana.com/) + +### 构建和运行 + +首先获取示例代码的最新版本: + +```shell +git clone https://github.com/solana-labs/break.git +cd break +``` + +接下来,按照git仓库的[README](https://github.com/solana-labs/break/blob/main/README.md)中的步骤操作。 From 45df6c7ff463efdc19af2d2964ec3843dfc98e97 Mon Sep 17 00:00:00 2001 From: Derick Date: Mon, 3 Jun 2024 23:33:45 +0800 Subject: [PATCH 2/5] code syntax replace --- docs/SolanaDocumention/programs/examples.md | 52 ++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/SolanaDocumention/programs/examples.md b/docs/SolanaDocumention/programs/examples.md index 87d2883..11df751 100644 --- a/docs/SolanaDocumention/programs/examples.md +++ b/docs/SolanaDocumention/programs/examples.md @@ -21,20 +21,20 @@ | 示例名称 | 描述 | 语言 | | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------- | -| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/account-data) | 在账户中保存地址、姓名、门牌号、街道和城市。 | 原生, Anchor | -| [检查账户](https://github.com/solana-developers/program-examples/tree/main/basics/checking-accounts) | 安全课程,展示如何进行账户检查。 | 原生, Anchor | -| [关闭账户](https://github.com/solana-developers/program-examples/tree/main/basics/close-account) | 展示如何关闭账户以取回租金。 | 原生, Anchor | -| [计数器](https://github.com/solana-developers/program-examples/tree/main/basics/counter) | 一个简单的计数器程序,包含所有不同的架构。 | 原生, Anchor, Seahorse, mpl-stack | -| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/create-account) | 如何在程序中创建系统账户。 | 原生, Anchor | -| [跨程序调用](https://github.com/solana-developers/program-examples/tree/main/basics/cross-program-invocation) | 使用手和杠杆的类比展示如何在程序中调用另一个程序。 | 原生, Anchor | -| [你好Solana](https://github.com/solana-developers/program-examples/tree/main/basics/hello-solana) | Hello world示例,仅在交易日志中打印hello world。 | 原生, Anchor | -| [PDA租金支付者](https://github.com/solana-developers/program-examples/tree/main/basics/pda-rent-payer) | 展示如何使用PDA的lamports支付新账户的费用。 | 原生, Anchor | -| [处理指令](https://github.com/solana-developers/program-examples/tree/main/basics/processing-instructions) | 展示如何处理指令数据字符串和u32。 | 原生, Anchor | -| [程序派生地址](https://github.com/solana-developers/program-examples/tree/main/basics/program-derived-addresses) | 展示如何使用种子引用PDA并在其中保存数据。 | 原生, Anchor | -| [重新分配](https://github.com/solana-developers/program-examples/tree/main/basics/realloc) | 展示如何增加和减少现有账户的大小。 | 原生, Anchor | -| [租金](https://github.com/solana-developers/program-examples/tree/main/basics/rent) | 你将在这里学习如何在程序中计算租金要求。 | 原生, Anchor | -| [仓库布局](https://github.com/solana-developers/program-examples/tree/main/basics/repository-layout) | 关于如何构建程序布局的建议。 | 原生, Anchor | -| [转移SOL](https://github.com/solana-developers/program-examples/tree/main/basics/transfer-sol) | 展示系统账户和PDA的不同SOL转移方法。 | 原生, Anchor, Seahorse | +| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/account-data) | 在账户中保存地址、姓名、门牌号、街道和城市。 | Native, Anchor | +| [检查账户](https://github.com/solana-developers/program-examples/tree/main/basics/checking-accounts) | 安全课程,展示如何进行账户检查。 | Native, Anchor | +| [关闭账户](https://github.com/solana-developers/program-examples/tree/main/basics/close-account) | 展示如何关闭账户以取回租金。 | Native, Anchor | +| [计数器](https://github.com/solana-developers/program-examples/tree/main/basics/counter) | 一个简单的计数器程序,包含所有不同的架构。 | Native, Anchor, Seahorse, mpl-stack | +| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/create-account) | 如何在程序中创建系统账户。 | Native, Anchor | +| [跨程序调用](https://github.com/solana-developers/program-examples/tree/main/basics/cross-program-invocation) | 使用手和杠杆的类比展示如何在程序中调用另一个程序。 | Native, Anchor | +| [你好Solana](https://github.com/solana-developers/program-examples/tree/main/basics/hello-solana) | Hello world示例,仅在交易日志中打印hello world。 | Native, Anchor | +| [PDA租金支付者](https://github.com/solana-developers/program-examples/tree/main/basics/pda-rent-payer) | 展示如何使用PDA的lamports支付新账户的费用。 | Native, Anchor | +| [处理指令](https://github.com/solana-developers/program-examples/tree/main/basics/processing-instructions) | 展示如何处理指令数据字符串和u32。 | Native, Anchor | +| [程序派生地址](https://github.com/solana-developers/program-examples/tree/main/basics/program-derived-addresses) | 展示如何使用种子引用PDA并在其中保存数据。 | Native, Anchor | +| [重新分配](https://github.com/solana-developers/program-examples/tree/main/basics/realloc) | 展示如何增加和减少现有账户的大小。 | Native, Anchor | +| [租金](https://github.com/solana-developers/program-examples/tree/main/basics/rent) | 你将在这里学习如何在程序中计算租金要求。 | Native, Anchor | +| [仓库布局](https://github.com/solana-developers/program-examples/tree/main/basics/repository-layout) | 关于如何构建程序布局的建议。 | Native, Anchor | +| [转移SOL](https://github.com/solana-developers/program-examples/tree/main/basics/transfer-sol) | 展示系统账户和PDA的不同SOL转移方法。 | Native, Anchor, Seahorse | ## 压缩 @@ -60,13 +60,13 @@ | 示例名称 | 描述 | 语言 | | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------ | -| [创建代币](https://github.com/solana-developers/program-examples/tree/main/tokens/create-token) | 如何创建代币并添加Metaplex元数据。 | Anchor, 原生 | -| [NFT铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/nft-minter) | 仅铸造一个代币数量,然后移除铸造权限。 | Anchor, 原生 | -| [PDA铸造权限](https://github.com/solana-developers/program-examples/tree/main/tokens/pda-mint-authority) | 展示如何更改铸造的铸造权限,以便在程序中铸造代币。 | Anchor, 原生 | -| [SPL代币铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/spl-token-minter) | 解释如何使用关联代币账户来跟踪代币账户。 | Anchor, 原生 | +| [创建代币](https://github.com/solana-developers/program-examples/tree/main/tokens/create-token) | 如何创建代币并添加Metaplex元数据。 | Anchor, Native | +| [NFT铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/nft-minter) | 仅铸造一个代币数量,然后移除铸造权限。 | Anchor, Native | +| [PDA铸造权限](https://github.com/solana-developers/program-examples/tree/main/tokens/pda-mint-authority) | 展示如何更改铸造的铸造权限,以便在程序中铸造代币。 | Anchor, Native | +| [SPL代币铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/spl-token-minter) | 解释如何使用关联代币账户来跟踪代币账户。 | Anchor, Native | | [代币交换](https://github.com/solana-developers/program-examples/tree/main/tokens/token-swap) | 广泛的示例,展示如何为SPL代币构建AMM(自动做市商)池。 | Anchor | -| [转移代币](https://github.com/solana-developers/program-examples/tree/main/tokens/transfer-tokens) | 展示如何使用CPI将SPL代币转移到代币程序中。 | Anchor, 原生, Seahorse | -| [Token-2022](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022) | 参见Token 2022(代币扩展)。 | Anchor, 原生 | +| [转移代币](https://github.com/solana-developers/program-examples/tree/main/tokens/transfer-tokens) | 展示如何使用CPI将SPL代币转移到代币程序中。 | Anchor, Native, Seahorse | +| [Token-2022](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022) | 参见Token 2022(代币扩展)。 | Anchor, Native | ## Token 2022(代币扩展) @@ -74,13 +74,13 @@ Token 2022是Solana上的新代币标准。它更灵活,允许你为代币铸 | 示例名称 | 描述 | 语言 | | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ------ | -| [基础](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/basics/anchor) | 如何创建代币、铸造和转移它。 | Anchor | -| [默认账户状态](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/default-account-state/native) | 此扩展允许你创建具有特定状态的代币账户,例如冻结状态。 | 原生 | -| [铸造关闭权限](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/mint-close-authority) | 旧代币程序中无法关闭铸造,现在可以了。 | 原生 | -| [多重扩展](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/multiple-extensions) | 展示如何为单个铸造添加多个扩展。 | 原生 | +| [基础](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/basics/anchor) | 如何创建代币、铸造和转移它。 | Native | +| [默认账户状态](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/default-account-state/native) | 此扩展允许你创建具有特定状态的代币账户,例如冻结状态。 | Native | +| [铸造关闭权限](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/mint-close-authority) | 旧代币程序中无法关闭铸造,现在可以了。 | Native | +| [多重扩展](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/multiple-extensions) | 展示如何为单个铸造添加多个扩展。 | Native | | [NFT元数据指针](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer) | 可以使用元数据扩展创建NFT并添加动态链上元数据。 | Anchor | -| [不可转移](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/non-transferable/native) | 例如用于成就、推荐计划或任何灵魂绑定代币。 | 原生 | -| [转移费用](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-fees) | 每次转移代币时,部分代币会保留在代币账户中,然后可以收集这些代币。 | 原生 | +| [不可转移](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/non-transferable/native) | 例如用于成就、推荐计划或任何灵魂绑定代币。 | Native | +| [转移费用](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-fees) | 每次转移代币时,部分代币会保留在代币账户中,然后可以收集这些代币。 | Native | | [转移钩子](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-hook) | 四个示例展示如何使用CPI从代币程序到你的程序中为代币添加额外功能。 | Anchor | ## Break From 5e40f931044839d2074fdfc507299a17ee34329c Mon Sep 17 00:00:00 2001 From: Derick Date: Mon, 3 Jun 2024 23:39:12 +0800 Subject: [PATCH 3/5] review translate article --- docs/SolanaDocumention/programs/examples.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/SolanaDocumention/programs/examples.md b/docs/SolanaDocumention/programs/examples.md index 11df751..d59b45d 100644 --- a/docs/SolanaDocumention/programs/examples.md +++ b/docs/SolanaDocumention/programs/examples.md @@ -56,7 +56,7 @@ ## 代币 -大多数Solana上的代币使用Solana程序库(SPL)代币标准。这里你可以找到许多关于如何铸造、转移、销毁代币以及如何在程序中与它们交互的示例。 +大多数Solana上的代币使用Solana程序库(SPL)代币标准。在这里你可以找到许多关于如何铸造、转移、销毁代币以及如何在程序中与它们交互的示例。 | 示例名称 | 描述 | 语言 | | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------ | @@ -85,9 +85,9 @@ Token 2022是Solana上的新代币标准。它更灵活,允许你为代币铸 ## Break -[Break](https://break.solana.com/)是一个React应用程序,给用户一种直观的感觉,展示Solana网络的快速和高性能。你能_打破_ Solana区块链吗?在15秒的游戏过程中,每次点击按钮或按键都会向集群发送一个新交易。尽可能快地敲击键盘,观看你的交易实时完成,而网络则从容应对! +[Break](https://break.solana.com/)是一个React应用程序,给用户一种直观的感觉,展示Solana网络的快速和高性能。*你能_打破_ Solana区块链吗?* 在15秒的游戏过程中,每次点击按钮或按键都会向集群发送一个新交易。尽可能快地敲击键盘,观看你的交易实时完成,而网络则从容应对! -Break可以在我们的Devnet、Testnet和Mainnet Beta网络上玩。在Devnet和Testnet上游戏是免费的,游戏会由网络水龙头资助。在Mainnet Beta上,用户每局游戏需支付0.08 SOL。会话账户可以通过本地密钥库钱包资助,或通过扫描Trust Wallet的二维码转移代币。 +Break可以在我们的Devnet、Testnet和Mainnet Beta网络上应用。在Devnet和Testnet上游戏是免费的,游戏会由网络水龙头资助。在Mainnet Beta上,用户每局游戏需支付`0.08` SOL。会话账户可以通过本地密钥库钱包资助,或通过扫描`Trust Wallet`的二维码转移代币。 [点击这里玩Break](https://break.solana.com/) From 8381b089f4ebaed65cb5d846e702f808affb9e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=A3=89=E5=A4=A7=E5=B8=88?= <1046166@qq.com> Date: Tue, 4 Jun 2024 00:37:37 +0800 Subject: [PATCH 4/5] Update examples.md --- docs/SolanaDocumention/programs/examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SolanaDocumention/programs/examples.md b/docs/SolanaDocumention/programs/examples.md index d59b45d..3fdf57e 100644 --- a/docs/SolanaDocumention/programs/examples.md +++ b/docs/SolanaDocumention/programs/examples.md @@ -38,7 +38,7 @@ ## 压缩 -包含一系列示例,展示如何在Solana上使用[状态压缩](/docs/advanced/state-compression.md)。主要集中在压缩NFT(cNFT)。 +包含一系列示例,展示如何在Solana上使用[状态压缩](https://solana.com/docs/advanced/state-compression)。主要集中在压缩NFT(cNFT)。 | 示例名称 | 描述 | 语言 | | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------ | From e1e468a42dd6f313e1cba8a22fbf512131d248a3 Mon Sep 17 00:00:00 2001 From: RuoMinggX <117256259+Patrickming@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:40:11 +0800 Subject: [PATCH 5/5] Review examples.md --- docs/SolanaDocumention/programs/examples.md | 119 ++++++++++---------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/docs/SolanaDocumention/programs/examples.md b/docs/SolanaDocumention/programs/examples.md index 3fdf57e..04181e8 100644 --- a/docs/SolanaDocumention/programs/examples.md +++ b/docs/SolanaDocumention/programs/examples.md @@ -1,95 +1,98 @@ # 程序示例 -"[Solana程序示例](https://github.com/solana-developers/program-examples)" GitHub仓库提供了多个子文件夹,每个文件夹包含不同Solana编程范式和语言的代码示例,旨在帮助开发者学习和实验Solana区块链开发。 +"[Solana程序示例](https://github.com/solana-developers/program-examples)" 的GitHub仓库提供了多个子文件夹,每个文件夹包含不同Solana编程范式和语言的代码示例,旨在帮助开发者学习和体验Solana区块链开发。 -你可以在`solana-developers/program-examples`中找到这些示例以及README文件,这些文件会解释如何运行不同的示例。大多数示例是自包含的,并且有原生Rust(即无框架)、[Anchor](https://www.anchor-lang.com/docs/installation)、[Seahorse](https://seahorse-lang.org/)的版本,还包含我们希望[看到的贡献示例](https://github.com/solana-developers/program-examples?tab=readme-ov-file#examples-wed-love-to-see)。 +你可以在`solana-developers/program-examples`中找到这些示例,以及解释如何运行这些示例的 README 文件。大多数示例是独立的,可在原生Rust(即无框架)、[Anchor](https://www.anchor-lang.com/docs/installation)、[Seahorse](https://seahorse-lang.org/)等语言版本,还包含我们希望[作为贡献](https://github.com/solana-developers/program-examples?tab=readme-ov-file#examples-wed-love-to-see)的示例列表。 在仓库中,你会找到以下子文件夹,每个文件夹内有各种示例程序: -- [程序示例](#程序示例) - - [基础](#基础) - - [压缩](#压缩) - - [预言机](#预言机) - - [代币](#代币) - - [Token 2022(代币扩展)](#token-2022代币扩展) - - [Break](#break) - - [构建和运行](#构建和运行) +- [基础](#基础) +- [压缩](#压缩) +- [预言机](#预言机) +- [代币](#代币) +- [Token 2022(代币扩展)](#token-2022代币扩展) +- [Break](#break) + - [构建和运行](#构建和运行) ## 基础 包含一系列示例,展示了使用原生Rust库构建Solana程序的基础步骤。这些示例旨在帮助开发者理解Solana编程的核心概念。 -| 示例名称 | 描述 | 语言 | -| ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------- | -| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/account-data) | 在账户中保存地址、姓名、门牌号、街道和城市。 | Native, Anchor | -| [检查账户](https://github.com/solana-developers/program-examples/tree/main/basics/checking-accounts) | 安全课程,展示如何进行账户检查。 | Native, Anchor | -| [关闭账户](https://github.com/solana-developers/program-examples/tree/main/basics/close-account) | 展示如何关闭账户以取回租金。 | Native, Anchor | -| [计数器](https://github.com/solana-developers/program-examples/tree/main/basics/counter) | 一个简单的计数器程序,包含所有不同的架构。 | Native, Anchor, Seahorse, mpl-stack | -| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/create-account) | 如何在程序中创建系统账户。 | Native, Anchor | -| [跨程序调用](https://github.com/solana-developers/program-examples/tree/main/basics/cross-program-invocation) | 使用手和杠杆的类比展示如何在程序中调用另一个程序。 | Native, Anchor | -| [你好Solana](https://github.com/solana-developers/program-examples/tree/main/basics/hello-solana) | Hello world示例,仅在交易日志中打印hello world。 | Native, Anchor | -| [PDA租金支付者](https://github.com/solana-developers/program-examples/tree/main/basics/pda-rent-payer) | 展示如何使用PDA的lamports支付新账户的费用。 | Native, Anchor | -| [处理指令](https://github.com/solana-developers/program-examples/tree/main/basics/processing-instructions) | 展示如何处理指令数据字符串和u32。 | Native, Anchor | -| [程序派生地址](https://github.com/solana-developers/program-examples/tree/main/basics/program-derived-addresses) | 展示如何使用种子引用PDA并在其中保存数据。 | Native, Anchor | -| [重新分配](https://github.com/solana-developers/program-examples/tree/main/basics/realloc) | 展示如何增加和减少现有账户的大小。 | Native, Anchor | -| [租金](https://github.com/solana-developers/program-examples/tree/main/basics/rent) | 你将在这里学习如何在程序中计算租金要求。 | Native, Anchor | -| [仓库布局](https://github.com/solana-developers/program-examples/tree/main/basics/repository-layout) | 关于如何构建程序布局的建议。 | Native, Anchor | -| [转移SOL](https://github.com/solana-developers/program-examples/tree/main/basics/transfer-sol) | 展示系统账户和PDA的不同SOL转移方法。 | Native, Anchor, Seahorse | +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------ | ---------------------------------------------------- | ----------------------------------- | +| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/account-data) | 在账户中保存地址、姓名、门牌号、街道和城市的地址。 | Native, Anchor | +| [检查账户](https://github.com/solana-developers/program-examples/tree/main/basics/checking-accounts) | 展示如何进行帐户检查的安全课程 | Native, Anchor | +| [关闭账户](https://github.com/solana-developers/program-examples/tree/main/basics/close-account) | 展示如何关闭账户以取回租金。 | Native, Anchor | +| [计数器](https://github.com/solana-developers/program-examples/tree/main/basics/counter) | 适用于所有不同架构的简单计数器程序。 | Native, Anchor, Seahorse, mpl-stack | +| [创建账户](https://github.com/solana-developers/program-examples/tree/main/basics/create-account) | 如何在程序中创建系统账户。 | Native, Anchor | +| [跨程序调用](https://github.com/solana-developers/program-examples/tree/main/basics/cross-program-invocation) | 使用手和杠杆的类比,展示如何在程序中调用另一个程序。 | Native, Anchor | +| [你好Solana](https://github.com/solana-developers/program-examples/tree/main/basics/hello-solana) | Hello world示例,仅在交易日志中打印hello world。 | Native, Anchor | +| [PDA租金支付者](https://github.com/solana-developers/program-examples/tree/main/basics/pda-rent-payer) | 展示如何使用 PDA 的 lamports 支付新账户的费用。 | Native, Anchor | +| [处理指令](https://github.com/solana-developers/program-examples/tree/main/basics/processing-instructions) | 展示如何处理指令数据字符串和u32。 | Native, Anchor | +| [程序派生地址](https://github.com/solana-developers/program-examples/tree/main/basics/program-derived-addresses) | 展示如何使用种子引用PDA并在其中保存数据。 | Native, Anchor | +| [重新分配](https://github.com/solana-developers/program-examples/tree/main/basics/realloc) | 展示如何增加和减少现有账户的大小。 | Native, Anchor | +| [租金](https://github.com/solana-developers/program-examples/tree/main/basics/rent) | 学习如何在程序中计算租金要求。 | Native, Anchor | +| [仓库布局](https://github.com/solana-developers/program-examples/tree/main/basics/repository-layout) | 关于如何组织程序结构的建议。 | Native, Anchor | +| [转移SOL](https://github.com/solana-developers/program-examples/tree/main/basics/transfer-sol) | 展示如何为系统账户和 PDA 转移 SOL 的不同方法。 | Native, Anchor, Seahorse | ## 压缩 包含一系列示例,展示如何在Solana上使用[状态压缩](https://solana.com/docs/advanced/state-compression)。主要集中在压缩NFT(cNFT)。 -| 示例名称 | 描述 | 语言 | -| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------ | -| [cNFT销毁](https://github.com/solana-developers/program-examples/tree/main/compression/cnft-burn) | 要销毁cNFT,可以将其烧毁。此示例展示了如何在程序中执行此操作。 | Anchor | -| [cNFT保险库](https://github.com/solana-developers/program-examples/tree/main/compression/cnft-vault/anchor) | 如何在程序中保管cNFT并再次发送出去。 | Anchor | -| [cutils](https://github.com/solana-developers/program-examples/tree/main/compression/cutils) | 一套工具,例如在程序中铸造和验证cNFT。 | Anchor | +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------ | --------------------------------------- | ------ | +| [cNFT - 销毁](https://github.com/solana-developers/program-examples/tree/main/compression/cnft-burn) | 销毁 cNFT 的示例。 | Anchor | +| [cNFT - 保险库](https://github.com/solana-developers/program-examples/tree/main/compression/cnft-vault/anchor) | 如何在程序中保管 cNFT 并再次发送出去。 | Anchor | +| [cutils](https://github.com/solana-developers/program-examples/tree/main/compression/cutils) | 一套工具,例如在程序中铸造和验证 cNFT。 | Anchor | ## 预言机 预言机允许在程序中使用链下数据。 -| 示例名称 | 描述 | 语言 | -| ------------------------------------------------------------------------ | -------------------------------------------------------------------- | ---------------- | -| [Pyth](https://github.com/solana-developers/program-examples/tree/main/oracles/pyth) | Pyth使代币的价格数据在链上程序中可用。 | Anchor, Seahorse | +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------ | ------------------------------------- | ---------------- | +| [Pyth](https://github.com/solana-developers/program-examples/tree/main/oracles/pyth) | Pyth 在链上程序中提供代币的价格数据。 | Anchor, Seahorse | ## 代币 大多数Solana上的代币使用Solana程序库(SPL)代币标准。在这里你可以找到许多关于如何铸造、转移、销毁代币以及如何在程序中与它们交互的示例。 -| 示例名称 | 描述 | 语言 | -| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------ | -| [创建代币](https://github.com/solana-developers/program-examples/tree/main/tokens/create-token) | 如何创建代币并添加Metaplex元数据。 | Anchor, Native | -| [NFT铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/nft-minter) | 仅铸造一个代币数量,然后移除铸造权限。 | Anchor, Native | -| [PDA铸造权限](https://github.com/solana-developers/program-examples/tree/main/tokens/pda-mint-authority) | 展示如何更改铸造的铸造权限,以便在程序中铸造代币。 | Anchor, Native | -| [SPL代币铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/spl-token-minter) | 解释如何使用关联代币账户来跟踪代币账户。 | Anchor, Native | -| [代币交换](https://github.com/solana-developers/program-examples/tree/main/tokens/token-swap) | 广泛的示例,展示如何为SPL代币构建AMM(自动做市商)池。 | Anchor | -| [转移代币](https://github.com/solana-developers/program-examples/tree/main/tokens/transfer-tokens) | 展示如何使用CPI将SPL代币转移到代币程序中。 | Anchor, Native, Seahorse | -| [Token-2022](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022) | 参见Token 2022(代币扩展)。 | Anchor, Native | +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------ | ------------------------------------------------------ | ------------------------ | +| [创建代币](https://github.com/solana-developers/program-examples/tree/main/tokens/create-token) | 如何创建代币并添加 metaplex 元数据。 | Anchor, Native | +| [NFT铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/nft-minter) | 铸造代币并移除铸币权限的示例。 | Anchor, Native | +| [PDA铸造权限](https://github.com/solana-developers/program-examples/tree/main/tokens/pda-mint-authority) | 展示如何更改铸币权限,从而在程序中铸造代币。 | Anchor, Native | +| [SPL代币铸造器](https://github.com/solana-developers/program-examples/tree/main/tokens/spl-token-minter) | 解释如何使用关联代币账户来跟踪代币账户。 | Anchor, Native | +| [代币交换](https://github.com/solana-developers/program-examples/tree/main/tokens/token-swap) | 详细展示如何为 SPL 代币构建自动化市场做市商(AMM)池。 | Anchor | +| [转移代币](https://github.com/solana-developers/program-examples/tree/main/tokens/transfer-tokens) | 展示如何使用CPI将SPL代币转移到代币程序中。 | Anchor, Native, Seahorse | +| [Token-2022](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022) | 参阅 Token 2022(代币扩展)。 | Anchor, Native | ## Token 2022(代币扩展) -Token 2022是Solana上的新代币标准。它更灵活,允许你为代币铸造添加16种不同的扩展,以增加更多功能。完整的扩展列表可以在[入门指南](https://solana.com/developers/guides/token-extensions/getting-started)中找到。 +Token 2022 是 Solana 上的新代币标准。它更加灵活,可以为代币铸造添加 16 种不同的扩展功能。扩展功能的完整列表可以在[入门指南](https://solana.com/developers/guides/token-extensions/getting-started)中找到。 -| 示例名称 | 描述 | 语言 | -| ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ------ | -| [基础](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/basics/anchor) | 如何创建代币、铸造和转移它。 | Native | -| [默认账户状态](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/default-account-state/native) | 此扩展允许你创建具有特定状态的代币账户,例如冻结状态。 | Native | -| [铸造关闭权限](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/mint-close-authority) | 旧代币程序中无法关闭铸造,现在可以了。 | Native | -| [多重扩展](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/multiple-extensions) | 展示如何为单个铸造添加多个扩展。 | Native | -| [NFT元数据指针](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer) | 可以使用元数据扩展创建NFT并添加动态链上元数据。 | Anchor | -| [不可转移](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/non-transferable/native) | 例如用于成就、推荐计划或任何灵魂绑定代币。 | Native | -| [转移费用](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-fees) | 每次转移代币时,部分代币会保留在代币账户中,然后可以收集这些代币。 | Native | -| [转移钩子](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-hook) | 四个示例展示如何使用CPI从代币程序到你的程序中为代币添加额外功能。 | Anchor | +| 示例名称 | 描述 | 语言 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------ | +| [基础](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/basics/anchor) | 如何创建代币、铸造和转移它。 | Anchor | +| [默认账户状态](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/default-account-state/native) | 此扩展允许你创建具有特定状态的代币账户,例如冻结状态。 | Native | +| [铸造关闭权限](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/mint-close-authority) | 旧代币程序中无法关闭铸造,现在可以了。 | Native | +| [多重扩展](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/multiple-extensions) | 展示如何为单个铸币添加多个扩展功能。 | Native | +| [NFT元数据指针](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer) | 使用元数据扩展创建 NFT 并添加动态链上元数据。 | Anchor | +| [不可转移](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/non-transferable/native) | 例如用于成就、推荐计划或任何灵魂绑定代币。 | Native | +| [转移费用](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-fees) | 每次代币转移时,代币账户中保留一些代币,然后可以收集这些代币。 | Native | +| [转移钩子](https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-hook) | 四个示例展示如何使用 CPI 从代币程序调用你的程序以添加额外功能。 | Anchor | ## Break -[Break](https://break.solana.com/)是一个React应用程序,给用户一种直观的感觉,展示Solana网络的快速和高性能。*你能_打破_ Solana区块链吗?* 在15秒的游戏过程中,每次点击按钮或按键都会向集群发送一个新交易。尽可能快地敲击键盘,观看你的交易实时完成,而网络则从容应对! +[Break](https://break.solana.com/)是一个React应用程序,给用户一种直观的感觉,展示Solana网络的快速和高性能。*你能打破Solana区块链吗?* 在15秒的游戏过程中,每次点击按钮或按键都会向集群发送一个新交易。尽可能快地敲击键盘,观看你的交易实时完成,而网络则从容应对! -Break可以在我们的Devnet、Testnet和Mainnet Beta网络上应用。在Devnet和Testnet上游戏是免费的,游戏会由网络水龙头资助。在Mainnet Beta上,用户每局游戏需支付`0.08` SOL。会话账户可以通过本地密钥库钱包资助,或通过扫描`Trust Wallet`的二维码转移代币。 +[Break](https://break.solana.com/) 是一个 React 应用,给用户提供 Solana 网络快速高效的直观感受。你能*打破* Solana 区块链吗?在 15 秒的游戏中,每次点击按钮或按键都会向集群发送一个新交易。尽可能快地点击键盘,观看你的交易实时确认,而网络能够应对这一切! -[点击这里玩Break](https://break.solana.com/) +Break 可以在我们的 开发网、测试网 和 主网Beta版 网络上玩。在 开发网 和 测试网 上,游戏是免费的,由网络水龙头资助。在 主网Beta版 上,用户每局游戏支付 0.08 SOL。会话账户可以通过本地密钥存储钱包资助或通过扫描 Trust Wallet 的二维码转移代币。 + +点击这里玩 Break + +[点击这里来玩Break](https://break.solana.com/) ### 构建和运行 @@ -100,4 +103,4 @@ git clone https://github.com/solana-labs/break.git cd break ``` -接下来,按照git仓库的[README](https://github.com/solana-labs/break/blob/main/README.md)中的步骤操作。 +接下来,按照git仓库中的[README](https://github.com/solana-labs/break/blob/main/README.md)文件的步骤进行操作。