Skip to content

Commit

Permalink
Merge pull request #177 from neo-project/dev
Browse files Browse the repository at this point in the history
Merge recent dev changes to master
  • Loading branch information
Celia18305 authored Jan 2, 2025
2 parents 7258b37 + 75a3156 commit 85e0394
Show file tree
Hide file tree
Showing 115 changed files with 1,772 additions and 290 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Neo Developer Portal is built using [Docusaurus](https://docusaurus.io/) v2.
4. Wait for a review
1. Neo developer portal team will review your PR
2. Acceptable PRs will be approved and merged into `dev` branch
3. Once your changes are merged into the `dev` branch, and it will automatically deploy to [docs.neo.org](https://docs.neo.org).
5. Release
1. Neo developer portal team will periodically merge `dev` into `main` branch and it will automatically deploy to [developers.neo.org](https://developers.neo.org/docs)
2. View history of releases on Github
Expand Down
2 changes: 1 addition & 1 deletion docs/faq/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ You can check any confirmed transaction on any blockchain explorer that is compa

## What browsers are available for Neo blockchain?

A full list of explorers for Neo N3 can be found on the [Neo website](https://developers.neo.org/resources).
A full list of explorers for Neo N3 can be found on the [Neo website](https://neo.org/dev#tooling).

## Is there an equivalent of the ERC-20 standard for Neo?

Expand Down
6 changes: 3 additions & 3 deletions docs/n3/develop/write/framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The .NET framework is an encapsulation of the Smart Contract API, which helps .N

Neo.SmartContract.Framework mainly provides the following API methods:

- A series of native contract methods that can be invoked in the smart contract,see [Neo.SmartContract.Framework.Native](https://developers.neo.org/docs/n3/reference/scapi/framework/native).
- Interoperability services layer methods, see [Neo.SmartContract.Framework.Service](https://developers.neo.org/docs/n3/reference/scapi/framework/services).
- Methods provided by the framework,see [Neo.SmartContract.Framework](https://developers.neo.org/docs/n3/reference/scapi/framework).
- A series of native contract methods that can be invoked in the smart contract,see [Neo.SmartContract.Framework.Native](../../reference/scapi/framework/native/index.md).
- Interoperability services layer methods, see [Neo.SmartContract.Framework.Service](../../reference/scapi/framework/services/index.md).
- Methods provided by the framework,see [Neo.SmartContract.Framework](../../reference/scapi/framework/index.md).

77 changes: 68 additions & 9 deletions docs/n3/develop/write/nep17.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ sidebar_position: 3
---
# NEP-17

The NEP-17 proposal is a replacement of the original NEP5 proposal, which outlines a token standard for the Neo blockchain that will provide systems with a generalized interaction mechanism for tokenized Smart Contracts.
The NEP-17 proposal is a replacement for the original NEP-5 proposal, outlining a token standard for the Neo blockchain. It establishes a generalized interaction mechanism for tokenized smart contracts.

NEP17 assets are recorded in the contract storage area, through updating account balance in the storage area, to complete the transaction.
NEP-17 assets are stored in the contract's storage area. Transactions are completed by updating account balances within this storage.

In the method definitions below, we provide both the definitions of the functions as they are defined in the contract as well as the invoke parameters.
In the method definitions below, we provide both the function definitions as specified in the contract and their corresponding invocation parameters.

## totalSupply

Expand Down Expand Up @@ -265,19 +265,78 @@ namespace NEP17
}
```

## NEP-17 changes
## Key Updates in NEP-17

This section summaries NEP-17 changes compared to the previous NEP-5 protocol.
This section summaries key updates and enhancements in NEP-17 compared to the previous NEP-5 protocol.

### onNEP17Payment

- The Transfer method should determine if the recipient is the deployed contract, and if so, call its `onNEP17Payment` method.
The `onNEP17Payment` method is a callback method that processes NEP-17 asset transfers in Neo smart contracts.

- The FungibleToken (NeoToken, GasToken) of the native contract calls the `onNEP17Tokens` method when transferring assets. The NonfungibleToken calls the `onNEP11Tokens` method when transferring assets.
#### Implementation example

The following is an example implementation (refer to the source code [here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/examples/Example.SmartContract.ContractCall/ContractCall.cs)).

```csharp
public class SampleContractCall : SmartContract
{
// Define the target contract hash for external calls.
[Hash160("0x13a83e059c2eedd5157b766d3357bc826810905e")]
private static readonly UInt160 DummyTarget;

// The onNEP17Payment method handles incoming NEP-17 payments.
public static void onNEP17Payment(UInt160 from, BigInteger amount, BigInteger data)
{
// Validate the input data; only proceed if it equals 123.
if (!data.Equals(123)) return;

// Get the current contract's hash and the caller's (token contract) hash.
UInt160 @this = Runtime.ExecutingScriptHash;
UInt160 tokenHash = Runtime.CallingScriptHash;

// Query the token contract to get the balance of the current contract.
BigInteger balanceOf = (BigInteger)Contract.Call(tokenHash, "balanceOf", CallFlags.All, @this);

// Call the target contract with the required parameters.
Contract.Call(DummyTarget, "dummyMethod", CallFlags.All, @this, tokenHash, balanceOf);
}
}
```

Explanation

- DummyTarget:
- Represents a predefined target contract hash.
- In this example, it's set to 0x13a83e059c2eedd5157b766d3357bc826810905e.

- onNEP17Payment Parameters:

- **from**: The address of the sender initiating the transfer.
- **amount**: The amount of NEP-17 tokens transferred.
- **data**: Additional data passed along with the transfer, used for custom business logic.

- Key Steps in the Method:

- Validate data: Only process the transfer if data equals 123.
- Fetch the balance: Query the token contract using the `balanceOf` method to retrieve the current token balance of the contract.
- External call: Invoke the dummyMethod of the target contract (DummyTarget) with parameters including the current contract hash, token hash, and the retrieved balance.

- Use Case:
- This method enables contracts to handle incoming NEP-17 payments and perform further actions such as notifying other contracts or executing specific business logic.

:::Note

- Ensure proper validation of incoming data to avoid unintended behavior.
- Use `Contract.Call` responsibly to avoid invoking malicious contracts.
- Implement additional security measures to validate `from`, `amount`, and `tokenHash` if needed.

- The Transfer method should determine if the recipient is the deployed contract, and if so, call its `onNEP17Payment` method.
- The FungibleToken (NeoToken, GasToken) of the native contract calls the `onNEP17Tokens` method when transferring assets. The NonfungibleToken calls the `onNEP11Tokens` method when transferring assets.
- The TokenSale contract should implement the `onNEP17Payment` method to receive assets and modify the Manifest file to trust the received asset contract.

### name method
:::

### Name method

The name method is moved to the manifest file, and you need to add `[DisplayName("Token Name")]` when writing the contract.

Expand All @@ -297,7 +356,7 @@ public class NEP17 : Nep17Token

### Transfer event

The transfer event is changed to Transfer event (first letter capitalized).
The `transfer` event is changed to `Transfer` event (first letter capitalized).

### IsPayable

Expand Down
2 changes: 1 addition & 1 deletion docs/n3/exchange/deploynode.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 1
## Install Neo client

1. Install [.NET Core Runtime](https://www.microsoft.com/net/download/core#/runtime) on the server, 5.0 and the later version.
2. From GitHub, download the [Neo-CLI](https://github.com/neo-project/neo-node/releases) program and enable the Neo node.
2. From GitHub, download the [Neo-CLI](https://github.com/neo-project/neo/releases) program and enable the Neo node.

## Install plugins

Expand Down
10 changes: 5 additions & 5 deletions docs/n3/exchange/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The system fee is charged for the instructions executed by NeoVM. For each instr
SystemFee = InvocationCost = The sum of all executed opcode fee
```

### **Instructions fee**
### Instructions fee

In Neo N3, NeoVM instructions fee has decreased to 1/1000 of the original fee in Neo Legacy, which significantly reduces the development cost.

Expand Down Expand Up @@ -159,7 +159,7 @@ You need to replace these strings when querying the user's balance:

##### Example

##### **Invoking balanceOf**
##### Invoking balanceOf

Suppose the account address is NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag, you need to convert it into Hash160 type and construct this parameter as a JSON object:

Expand Down Expand Up @@ -215,7 +215,7 @@ After sending the request, you will get the following response:

To get the balance divide the returned value by decimals, without needing of data conversion.

##### **Invoking decimals**
##### Invoking decimals

Request Body:

Expand Down Expand Up @@ -255,7 +255,7 @@ After sending the request, you will get the following response:

It returns integer 8.

##### **Invoking symbol**
##### Invoking symbol

Request Body:

Expand Down Expand Up @@ -295,7 +295,7 @@ After sending the request, you will get the following response:

It returns "R0FT" which can be decoded to "GAS".

##### **Calculating the User Balance**
##### Calculating the User Balance

According to all the returned values, we can calculate the user balance as follows:
The balance = return / 10<sup>decimals</sup>
Expand Down
4 changes: 2 additions & 2 deletions docs/n3/node/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ There are two full-node programs:

| | Neo-GUI | Neo-CLI |
| ---- | ---------------------------------------- | ---------------------------------------- |
| Releases | [Download](https://github.com/neo-ngd/Neo3-GUI/releases) | [Download](https://github.com/neo-project/neo-cli/releases) |
| Source code | [GitHub](https://github.com/neo-ngd/Neo3-GUI) | [GitHub](https://github.com/neo-project/neo-cli) |
| Releases | [Download](https://github.com/neo-ngd/Neo3-GUI/releases) | [Download](https://github.com/neo-project/neo/releases) |
| Source code | [GitHub](https://github.com/neo-ngd/Neo3-GUI) | [GitHub](https://github.com/neo-project/neo) |

## Neo-GUI and Neo-CLI comparison

Expand Down
6 changes: 3 additions & 3 deletions docs/n3/node/cli/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The following table lists the minimum and recommended hardware requirements for

## Installing Neo-CLI package

1. Download the latest [Neo-CLI](https://github.com/neo-project/neo-cli/releases) package according to your operating system on GitHub and unzip it.
1. Download the latest [Neo-CLI](https://github.com/neo-project/neo/releases) package according to your operating system on GitHub and unzip it.

2. On Linux, install the LevelDB and SQLite3 dev packages.

Expand Down Expand Up @@ -66,10 +66,10 @@ You can download and compile the Neo-CLI source directly from GitHub.
### Installing required files
1. Git clone Neo-CLI source code from [GitHub](https://github.com/neo-project/neo-node) or using the following command:
1. Git clone Neo-CLI source code from [GitHub](https://github.com/neo-project/neo) or using the following command:
```
git clone https://github.com/neo-project/neo-node.git
git clone https://github.com/neo-project/neo.git
```
2. Download [LevelDB](https://github.com/neo-ngd/leveldb/releases) and unzip the package for later use.
Expand Down
29 changes: 29 additions & 0 deletions docs/n3/reference/Opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3084,6 +3084,35 @@ This opcode set defines instructions for stack operations, compound-type handlin
Keeps only characters left of the specified point in a string.
</td>
</tr>
<tr>
<td><a class="anchor" name="8E"></a><a href="#8E">8E</a></td>
<td>RIGHT</td>
<td>
<table class="stack table-bordered">
<tbody>
<tr>
<td>b</td>
<td>a</td>
<td></td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="stack table-bordered">
<tbody>
<tr>
<td>a[^b]</td>
<td></td>
</tr>
</tbody>
</table>
</td>
<td>a[^b]</td>
<td>
Keeps only characters right of the specified point in a string.
</td>
</tr>
<tr>
<td><a class="anchor" name="90"></a><a href="#90">90</a></td>
<td>INVERT</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/n3/reference/scapi/framework/native/Gas/Transfer.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **GAS.Transfer Method**
# GAS.Transfer Method

Transfers GAS

Expand Down
2 changes: 1 addition & 1 deletion docs/n3/reference/scapi/framework/native/Neo/BalanceOf.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **NEO.BalanceOf** Method (UInt160)
# NEO.BalanceOf Method (UInt160)

Gets the NEO balance in the account.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static string Name() => "name of the token";

在开发智能合约时,必须将应用程序的数据存储在区块链上。当创建一个智能合约或者交易使用这个合约时,合约的代码需要读写它的存储空间。存储在智能合约存储区中的所有数据在智能合约的调用期间会自动持久化。区块链中的全节点会存储链上每一个智能合约的状态。

Neo提供了基于键值对的数据访问接口。可以使用键从智能合约中读取、删除数据或将数据记录写入到智能合约中。此外,智能合约可以检索并将它们的存储上下文发送给其他合约,从而委托其他合约管理它们的存储区域。在C#开发中,智能合约可以使用 `Storage` 类来读写持久性存储区。 `Storage` 类是一个静态类,不需要构造函数。 `Storage` 类的方法可以查看 [API 参考文档](../../reference/scapi/framework/services/Storage.md)
Neo提供了基于键值对的数据访问接口。可以使用键从智能合约中读取、删除数据或将数据记录写入到智能合约中。此外,智能合约可以检索并将它们的存储上下文发送给其他合约,从而委托其他合约管理它们的存储区域。在C#开发中,智能合约可以使用 `Storage` 类来读写持久性存储区。 `Storage` 类是一个静态类,不需要构造函数。 `Storage` 类的方法可以查看 [API 参考文档](../../reference/scapi/framework/services/Storage/index.md)

例如,如果你想将token的总供应量存储到存储区:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Neo 智能合约框架(Neo.SmartContract.Framework)是对智能合约开发

Neo.SmartContract.Framework 提供了以下重要的 API 方法集:

- 原生合约中的一系列方法,请参阅 [Neo.SmartContract.Framework.Native](https://developers.neo.org/zh/docs/n3/reference/scapi/framework/native)
- 互操作服务层的方法,请参阅 [Neo.SmartContract.Framework.Service](https://developers.neo.org/zh/docs/n3/reference/scapi/framework/services)
- 智能合约框架本身提供的常用方法,请参阅 [Neo.SmartContract.Framework](https://developers.neo.org/zh/docs/n3/reference/scapi/framework/framework)
- 原生合约中的一系列方法,请参阅 [Neo.SmartContract.Framework.Native](../../reference/scapi/framework/native/index.md)
- 互操作服务层的方法,请参阅 [Neo.SmartContract.Framework.Service](../../reference/scapi/framework/services/index.md)
- 智能合约框架本身提供的常用方法,请参阅 [Neo.SmartContract.Framework](../../reference/scapi/framework/index.md)

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 1
## 安装节点

1. 安装 Neo 节点的运行环境 [.NET Core Runtime](https://www.microsoft.com/net/download/core#/runtime),5.0 或以上版本。
2. 在 GitHub 上下载 [neo-cli](https://github.com/neo-project/neo-node/releases) 程序包并启动 Neo 节点。
2. 在 GitHub 上下载 [neo-cli](https://github.com/neo-project/neo/releases) 程序包并启动 Neo 节点。

## 安装插件

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ symbol

##### 调用示例

##### **调用 balanceOf**
##### 调用 balanceOf

假设用户账户地址是 NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag,你需要将其转换为 Hash160 类型并将此参数构造成 JSON 对象,如下所示:

Expand Down Expand Up @@ -213,7 +213,7 @@ symbol

返回值无需转换,只需除以 decimals 得到余额即可。

##### **调用 decimals**
##### 调用 decimals

请求正文:

Expand Down Expand Up @@ -253,7 +253,7 @@ symbol

返回值为整数 **8**

##### **调用 symbol**
##### 调用 symbol

请求正文:

Expand Down Expand Up @@ -293,7 +293,7 @@ symbol

返回值 "R0FT" 可以被 base64 解码为 "GAS"。

##### **计算用户余额**
##### 计算用户余额

根据所有返回值,可以计算出用户余额为:
用户余额 = balanceOf 返回值 / 10<sup>decimals</sup>。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ NEP17 协议是 Neo 补充协议中的第17号协议。其目的是为 Neo 建

#### 存储区

每个被部署到 Neo 区块链上的智能合约程序,都拥有一个私有存储区用于存放应用程序的数据。当创建一个智能合约或者交易使用这个合约时,合约的代码需要读写它的存储空间。每个合约都可以声明一块存储区,声名方式为在合约的类上添加一段自定义特性。详情请参见 [存储区操作](reference/scapi/framework/services/storage.md)
每个被部署到 Neo 区块链上的智能合约程序,都拥有一个私有存储区用于存放应用程序的数据。当创建一个智能合约或者交易使用这个合约时,合约的代码需要读写它的存储空间。每个合约都可以声明一块存储区,声名方式为在合约的类上添加一段自定义特性。详情请参见 [存储区操作](reference/scapi/framework/services/storage/index.md)

#### NEF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

## 安装 Neo-CLI 程序包

1. 在 GitHub 上下载系统对应的 [Neo-CLI](https://github.com/neo-project/neo-node/releases) 程序包并解压。
1. 在 GitHub 上下载系统对应的 [Neo-CLI](https://github.com/neo-project/neo/releases) 程序包并解压。

2. 对于 Linux 系统,需要安装 LevelDB 和 SQLite3 开发包。

Expand Down Expand Up @@ -52,17 +52,17 @@
sudo apt-get install librocksdb-dev
```

对于 Windows 系统,[Neo-CLI](https://github.com/neo-project/neo-cli/releases) 的安装包中已经包含了 LevelDB,可跳过该步骤。
对于 Windows 系统,[Neo-CLI](https://github.com/neo-project/neo/releases) 的安装包中已经包含了 LevelDB,可跳过该步骤。


## 通过源码发布 Neo-CLI

### 准备工作

1. 下载 [neo-node](https://github.com/neo-project/neo-node) 项目,或通过 Git 命令克隆项目。
1. 下载 [neo-node](https://github.com/neo-project/neo) 项目,或通过 Git 命令克隆项目。

```
$ git clone https://github.com/neo-project/neo-node.git
$ git clone https://github.com/neo-project/neo.git
```

2. 下载对应版本的 [LevelDB](https://github.com/neo-ngd/leveldb/releases) 并解压备用。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Neo 有两个全节点程序:

| | Neo-GUI | Neo-CLI |
| ------ | -------------------------------------------------------- | ----------------------------------------------------------- |
| 程序 | [下载地址](https://github.com/neo-ngd/Neo3-GUI/releases) | [下载地址](https://github.com/neo-project/neo-cli/releases) |
| 源代码 | [Github](https://github.com/neo-ngd/Neo3-GUI) | [Github](https://github.com/neo-project/neo-cli) |
| 程序 | [下载地址](https://github.com/neo-ngd/Neo3-GUI/releases) | [下载地址](https://github.com/neo-project/neo/releases) |
| 源代码 | [Github](https://github.com/neo-ngd/Neo3-GUI) | [Github](https://github.com/neo-project/neo) |

## Neo-GUI 与 Neo-CLI 功能对比

Expand Down
Loading

0 comments on commit 85e0394

Please sign in to comment.