Skip to content

Commit

Permalink
Merge pull request #120 from neo-project/dev
Browse files Browse the repository at this point in the history
merge dev updates to master
  • Loading branch information
Celia18305 authored Jun 11, 2024
2 parents d7f2743 + 313c3e8 commit 9e0990e
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 112 deletions.
8 changes: 4 additions & 4 deletions docs/n3/develop/deploy/invoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ Three fields related to the contract invocation permission are defined in the co
| Fields | Type | Description |
| ------------- | ----------------------------- | ------------------------------------------------------------ |
| `Groups` | `ContractGroup[]` | Defines a group of trusted contracts, consisting of a public key and a signature of contract hash. |
| `Permissions` | `ContractPermission[]` | This field is an array containing a permission object, which defines other contracts and methods that the contract wants to call. The contract can be ScriptHash, Group, or wildcard \*. The method is the method name or wildcard \*. Contracts or methods not declared in the manifest cannot be called by the contract. |
| `Trusts` | `WildcardContainer<UInt160>` | Defines other contracts trusted by the contract. The contract can be ScriptHash, Group, or wildcard *. If a contract is trusted, the user will not receive any warning message when the contract is called. |
| `Permissions` | `ContractPermission[]` | This field is an array containing a permission object, which defines other contracts and methods that the contract wants to call. The contract can be ScriptHash, Group, or `Permission.Any`. The method is the method name or `Method.Any`. Contracts or methods not declared in the manifest cannot be called by the contract. |
| `Trusts` | `WildcardContainer<ContractPermissionDescriptor>` | Defines other contracts trusted by the contract. The contract can be ScriptHash, Group, or `Permission.Any`. If a contract is trusted, the user will not receive any warning message when the contract is called. |

Assuming that the contract A calls the contract B, the following table details the invoking behavior and wallet behavior of the contract in various setting scenarios.

Expand All @@ -125,8 +125,8 @@ Assuming that the contract A calls the contract B, the following table details t
| Permissions of contract A include contract B<br/>Trusts of contract B include contract A | None | Default and adds CustomContract | Yes |
| Permissions of contract A include contract B<br/>Trusts of contract B do not include contract A | Prompts that contract A will call contract B, and asks whether to authorize the signature to contract B. | Default and adds CustomContract according to the user's decision | Determined by the user |
| Permissions of contract A include a Groups B | Prompts that contract A will call any contract in group B and asks whether to authorize the signature to group B. | Default and adds CustomGroups according to the user's decision | Determined by the user |
| The contract defined in the Permissions of contract A is wildcard * and the method is m<br/>{"contract":"\*", "method": "m"} | Prompts that contract A will call the method m of any contract and asks whether to authorize the signature to contract B. | Default or Global according to the user's decision | Determined by the user |
| The contract defined in the Permissions of contract A is wildcard * and the method is wildcard \*<br/>{"contract":"\*", "method": "\*"} | Prompts that contract A will call any method of any contract and asks whether to set the signature to Global. | Default or Global according to the user's decision | Determined by the user |
| The contract defined in the Permissions of contract A is Permission.Any * and the method is m<br/>{"contract":"\*", "method": "m"} | Prompts that contract A will call the method m of any contract and asks whether to authorize the signature to contract B. | Default or Global according to the user's decision | Determined by the user |
| The contract defined in the Permissions of contract A is Permission.Any * and the method is Method.Any \*<br/>{"contract":"\*", "method": "\*"} | Prompts that contract A will call any method of any contract and asks whether to set the signature to Global. | Default or Global according to the user's decision | Determined by the user |

## Invoking a contract with wallets/dAPIs

Expand Down
4 changes: 2 additions & 2 deletions docs/n3/develop/write/1_dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This document covers the usage of project templates and the compiler. For furthe

## Neo.SmartContract.Template

Neo.SmartContract.Template is a project template used when developing Neo smart contracts. After installing the template, you can create a Neo smart contract project using either the Terminal or Visual Studio.
[Neo.SmartContract.Template](https://www.nuget.org/packages/Neo.SmartContract.Template) is a project template used when developing Neo smart contracts. After installing the template, you can create a Neo smart contract project using either the Terminal or Visual Studio.

### Install the template

Expand All @@ -36,7 +36,7 @@ dotnet new install Neo.SmartContract.Template
dotnet new list
```

There are three default templates available after installing Neo.SmartContract:
There are three default templates available after installing [Neo.SmartContract.Template](https://www.nuget.org/packages/Neo.SmartContract.Template):

- neocontractowner - Standard contract template with Owner, including GetOwner and SetOwner methods)

Expand Down
4 changes: 2 additions & 2 deletions docs/n3/develop/write/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The Manifest file includes the following fields.
| Groups | ContractGroup[] Consisting of a public key and a signature on the contract hash | Defines a group of trusted contracts. Contracts in a group trusts each other and can be invoked by each other, without prompting the user any warnings. For example, a series of contracts that call each other for a DeFi project. A group is identified by a public key and must has a signature for the contract hash to prove that the contract is included in the group. |
| SupportedStandards | string[] | Supported NEP standard, equivalent to NEP-10 in Neo Legacy.x |
| Abi | ContractAbi | NEP-14 (NeoContract ABI) Description of smart contract methods (name, parameters, return value, offset, safe or not), events (name, parameters) |
| Permissions | ContractPermission[] Consisting of the contract and its method names | This field is an array containing a permission object, which defines other contracts and methods that the contract wants to call. The contract can be ScriptHash, Group, or wildcard \*. The method is the method name or wildcard \*. Contracts or methods not declared in the manifest cannot be called by the contract. |
| Trusts | WildcardContainer<UInt160\> | Defines other contracts trusted by the contract. The contract can be ScriptHash, Group, or wildcard *. If a contract is trusted, the user will not receive any warning message when the contract is called. |
| Permissions | ContractPermission[] Consisting of the contract and its method names | This field is an array containing a permission object, which defines other contracts and methods that the contract wants to call. The contract can be ScriptHash, Group, or Permission.Any \*. The method is the method name or Permission.Any \*. Contracts or methods not declared in the manifest cannot be called by the contract. |
| Trusts | WildcardContainer<ContractPermissionDescriptor\> | Defines other contracts trusted by the contract. The contract can be ScriptHash, Group, or Permission.Any *. If a contract is trusted, the user will not receive any warning message when the contract is called. |
| Extra | object | Other user-defined data, such as developer, email, URL, contract profile, etc. |

24 changes: 24 additions & 0 deletions docs/n3/develop/write/nep11.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ The base class `Nep11Token` also provides the following methods and events:
Compatibility checks will be activated for any contract that includes the `[SupportedStandards("NEP-17")]` or `[SupportedStandards("NEP-11")]` attribute.
The Compatibility Check reviews method names, parameters, return values, events, and similar elements to ensure they comply with the standard, and alerts about any failures in the check.

### NFT Royalty Standard

To allow developers to receive better royalty benefits from NFTs, it is recommended to implement the Royalty standard in the contract.

The NFT store can query the royalty amount by calling the contract's `RoyaltyInfo` method. At this point, the total NFT transaction price will be the NFT selling price plus the royalty amount.

In this example code, the royalty fee is 1/1000th of the NFT's selling price, rounded down, regardless of the transaction currency. For instance, if the NFT sells for 0.1 GAS, the royalty fee is 0.0001 GAS (10,000 Datoshi). If the NFT sells for 10 NEO, the royalty fee is 0 NEO.

```csharp
[Safe]
public static Map<string, object>[] RoyaltyInfo(ByteString tokenId, UInt160 royaltyToken, BigInteger salePrice)
{
ExecutionEngine.Assert(OwnerOf(tokenId) != null, "This TokenId doesn't exist!");
var royaltyInfo = new Map<string, object>();
royaltyInfo["royaltyRecipient"] = InitialRecipient;
royaltyInfo["royaltyAmount"] = salePrice / 1000;
return new[] { royaltyInfo };
}
```

## See also

[NEP-11 Proposal](https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki)
Expand All @@ -165,3 +185,7 @@ The Compatibility Check reviews method names, parameters, return values, events,

[NeoVerse Document](https://github.com/chenzhitong/neoverse-readme)

[NFT Royalty Standard](https://github.com/neo-project/proposals/blob/master/nep-24.mediawiki)

[NFT Royalty Example](https://github.com/neo-project/neo-devpack-dotnet/blob/master/examples/Example.SmartContract.SampleRoyaltyNEP11Token/SampleRoyaltyNEP11Token.cs)

2 changes: 1 addition & 1 deletion docs/n3/develop/write/nep17.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace NEP17
[ContractVersion("0.0.1")]
[ContractDescription("A sample NEP-17 token")]
[ContractSourceCode("https://github.com/neo-project/neo-devpack-dotnet/tree/master/examples/")]
[ContractPermission(Permission.WildCard, Method.WildCard)]
[ContractPermission(Permission.Any, Method.Any)]
[SupportedStandards(NepStandard.Nep17)]
public class SampleNep17Token : Nep17Token
{
Expand Down
103 changes: 0 additions & 103 deletions docs/n3/gettingstarted/3_develop.md

This file was deleted.

File renamed without changes.
80 changes: 80 additions & 0 deletions docs/n3/gettingstarted/develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Developing a contract

We have completed setting up the private chain and configuring the node. In this section we will walk you through configuring the environment, writing, and compiling an NEP17 contract using C#.

The following steps are applicable to multiple system platforms, such as Windows, macOS, and Ubuntu.

## Installing tools

1. Download and install [Visual Studio Code](https://code.visualstudio.com/Download)

2. Download and install [.NET 8.0 SDK](https://dotnet.microsoft.com/download)

3. Run the command line and enter the following command to check if you have installed SDK successfully.

```powershell
dotnet --list-sdks
```

If there is no issue the SDK version number is displayed.

## Installing contract template

[Neo.SmartContract.Template](https://www.nuget.org/packages/Neo.SmartContract.Template) is a project template used when developing Neo smart contracts. After installing the template, you can create a Neo smart contract project using either the Terminal or Visual Studio.

### Install the template

```
dotnet new install Neo.SmartContract.Template
```

### List all dotnet templates

```
dotnet new list
```

These default templates are available after installing [Neo.SmartContract.Template](https://www.nuget.org/packages/Neo.SmartContract.Template):

- neocontractowner - Standard contract template with the Owner, including the GetOwner and SetOwner methods.

- neocontractoracle - A contract template using OracleRequest.

- neocontractnep17 - NEP-17 contract template, including the Mint and Burn methods.

:::note

The `neocontract` template previously used has been renamed to `neocontractowner`.

:::

### Create a project using templates with Terminal

```
dotnet new neocontractnep17
```

The project name defaults to the name of the current directory. You can also specify the project name with `-n, --name <name>`, e.g. `dotnet new neocontractnep17 -n MyFirstContract`.

## Compiling contract file

In the Terminal interface, go to the project path and run the following command to build your contract:

```
dotnet build
```

or

```
nccs
```

Related contract files are outputted under `bin\sc` path in the contract project directory.

## See also

For more information about writing contracts, refer to [Basics](../develop/write/basics.md).

For information about differences between Neo N3 and Neo Legacy contracts, refer to [Differences than Neo Legacy](../develop/write/difference.md)

File renamed without changes.
File renamed without changes.

0 comments on commit 9e0990e

Please sign in to comment.