Skip to content

Commit

Permalink
Merge pull request #106 from neo-project/Add-migration-and-gettingsta…
Browse files Browse the repository at this point in the history
…rted

Add migration and getting started files back and other updates
  • Loading branch information
Celia18305 committed May 11, 2024
2 parents dce6556 + bfbe525 commit 2a4ccd6
Show file tree
Hide file tree
Showing 52 changed files with 396 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/n3/Advances/_category_.json
@@ -1,4 +1,4 @@
{
"label": "Advances",
"position": 5
"position": 4
}
2 changes: 1 addition & 1 deletion docs/n3/develop/_category_.json
@@ -1,4 +1,4 @@
{
"label": "Development Guide",
"position": 6
"position": 5
}
31 changes: 30 additions & 1 deletion docs/n3/develop/deploy/invoke.md
Expand Up @@ -17,7 +17,7 @@ Use the RPC API [getcontractstate method](../../reference/rpc/latest-version/api

The detailed contract information is displayed in Neo-GUI. You can also view the manifest and nef files.

## Invoking a contract
## Invoking a contract with Neo Node Clients

### Invoking a contract using Neo-CLI

Expand Down Expand Up @@ -128,3 +128,32 @@ Assuming that the contract A calls the contract B, the following table details t
| 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 |

## Invoking a contract with wallets/dAPIs

You can use browser wallets to invoke a smart contract, which is helpful for creating a front-end interface on Neo.

### Available Wallets

Below is a list of several wallets that allow users to invoke smart contracts on front-end interfaces across different platforms. While additional wallets may also be available, the ones listed here operate with slight variations in invocation.

- [Neoline](https://neoline.io/en/)
- [Neoline Dapi Doc](https://neoline.io/dapi/N3.html)

#### Desktop

- [Neon](https://neon.coz.io/)
- [WalletConnect SDK](https://github.com/CityOfZion/wallet-connect-sdk)
- [WalletConnect SDK Guide](https://github.com/CityOfZion/wallet-connect-sdk/blob/main/README.md)
- [O3 Wallet](https://o3.network/#/wallet)

#### Mobile

- [OneGate](https://onegate.space/)
- [Neoline Mobile](https://neoline.io/en/)

OneGate & Neoline Mobile support the [Neo Dapi](https://github.com/neo-ngd/neo-dapi-monorepo). Here you can learn more about [Neo dapi demo](https://github.com/neo-ngd/neo-dapi-demo).

### Usage Example

Here is an [example](https://neo-dapp-demo.vercel.app/) that is applicable to all of the wallets listed above. In this example, you can learn how to connect to a wallet and call methods supported by these wallets. Corresponding source code can be found at [dAPP Demo](https://github.com/ShaySong99/neo-dapp-demo).

2 changes: 1 addition & 1 deletion docs/n3/exchange/_category_.json
@@ -1,5 +1,5 @@
{
"label": "Exchange",
"position": 8
"position": 7
}

2 changes: 1 addition & 1 deletion docs/n3/foundation/_category_.json
@@ -1,4 +1,4 @@
{
"label": "Foundational topics",
"position": 1
"position": 2
}
4 changes: 4 additions & 0 deletions docs/n3/gettingstarted/_category_.json
@@ -0,0 +1,4 @@
{
"label": "Getting Started (C#)",
"position": 1
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/gettingstarted/assets/3_1545037391347.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/gettingstarted/assets/compile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/gettingstarted/assets/contractfile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/gettingstarted/assets/neocontract.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/gettingstarted/assets/nuget.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions docs/n3/gettingstarted/deploy.md
@@ -0,0 +1,62 @@
# Deploying and invoking contract

In the previous section we have compiled an NEP17 contract file (NEP17.nef) and contract descriptive file (NEP17.manifest.json), next we will move on to deployment and invocation of the contract with Neo-CLI.

## Deploying contract

In Neo-CLI, input the deploy command `deploy <nefFilePath> [manifestFile]` , for example:

```bash
deploy NEP17.nef
```

Or

```bash
deploy NEP17.nef NEP17.manifest.json
```

After the command is executed, the NEP17 contract is deployed and the related fee is charged by the system automatically.

```bash
neo> deploy NEP17.nef
Script hash: 0xb7f4d011241ec13db16c0e3484bdd5dd9a536f26
Gas: 10.1477624

Signed and relayed transaction with hash=0xe03aade81fb96c44e115a1cc9cfe984a9df4a283bd10aa0aefa7ebf3e296f757
```

For more information, refer to [Deploying Smart Contracts](../develop/deploy/deploy.md).

## Invoking contract

Now we can invoke the contract using the Neo-CLI command `invoke`:

```bash
invoke <scriptHash> <operation> [contractParameters=null] [witnessAddress=null]
```

For example:

```bash
invoke 0xb7f4d011241ec13db16c0e3484bdd5dd9a536f26 symbol
```

After executed successfully, the following information is printed:

```bash
Invoking script with: '10c00c046e616d650c14f9f81497c3f9b62ba93f73c711d41b1eeff50c2341627d5b52'
VM State: HALT
Gas Consumed: 0.0103609
Evaluation Stack: [{"type":"ByteArray","value":"VG9rZW5TeW1ib2w="}]

relay tx(no|yes):
```

Where:

- VM State: `HALT` indicates the vm executed successfully; `FAULT` indicates the vm exited during execution due to an exception.
- Evaluation Stack: the result of contract execution, where the value is encoded with Base64 when it is a string or ByteArray.
- You can do the data format conversion [here](https://neo.org/converter/) `VG9rZW5TeW1ib2w=` => `TokenSymbol`

For more information, refer to [Invoking Smart Contracts](../develop/deploy/invoke.md).
103 changes: 103 additions & 0 deletions docs/n3/gettingstarted/develop.md
@@ -0,0 +1,103 @@
# 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 6.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

[Neo3.SmartContract.Templates](https://www.nuget.org/packages/Neo3.SmartContract.Templates/) contains the latest contract compiler and a hello contract template. The latest version is recommended:

```powershell
dotnet new -i Neo3.SmartContract.Templates
```

## Creating a contract project

1. Create a folder named `Nep17` as the contract project。

2. In the command line go to the `Nep17` path and then enter the command to generate code files based on the template.

```powershell
dotnet new neo3-contract
```

You can find the files named by the folder name under `Nep17` directory: Nep17.cs and Nep17.csproj.

If you want to specify the file name, add the option -n, for example, `dotnet new neo3-contract -n tokenA`.

## Editing NEP17 code

Since many developers are concerned about how to publish their own contract assets on the Neo block chain, now let's proceed with the NEP17 contract development on private chain.

1. Download all the .cs files from [NEP17 Template](https://github.com/neo-project/examples/tree/master/csharp/NEP17) and place them under the `Nep17` directory.

2. Remove the original Nep17.cs generated by the HelloContract template.

3. Run VS Code and install the C# extension as prompted.

![](../../zh-cn/gettingstarted/assets/extension.png)

4. Open the `Nep17` folder to edit the Nep17 template。

In comparison with Neo Legacy, the Neo N3 NEP17 sample has the following changes:

- Added the customized attributes above the smart contract class

```
[DisplayName("Token Name")]
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "dev@neo.org")]
[ManifestExtra("Description", "This is a NEP17 example")]
[SupportedStandards("NEP-17")]
[ContractPermission("*", "onNEP17Payment")]
public class NEP17 : SmartContract
……
```

- Removed the Name method

- Added _deploy method, which will be executed immediately after the contract is deployed

- Added the Update and Destroy methods

- All the Crowdsale methods are in the NEP17.Crowdsale.cs file. Developers can choose to use this file if need be.

- Called the onNEP17Payment method of the recipient in the Transfer method

- Implemented onNEP17Payment to automatically execute the smart contract when NEP17 assets are received.

- Major changes occurred in smart contract framework. For details refer to [Smart Contract API](https://docs.neo.org/docs/en-us/reference/scapi/interop.html)

For more information refer to [NEP-17](https://docs.neo.org/docs/en-us/develop/write/nep17.html) .

## Compiling contract file

Run the following command to build your contract:

```powershell
dotnet build
```

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)

19 changes: 19 additions & 0 deletions docs/n3/gettingstarted/enviroment.md
@@ -0,0 +1,19 @@
# Setting up local network

## Setting up a private chain

Neo provides a test net for development, debugging and testing purposes. Besides, you can also choose to set up your own private chain where you can get more flexibility with plenty of test tokens. You can pick one of the following options:

- [Set up a private chain with one node](../develop/network/private-chain/solo.md)
- [Set up a private chain with multiple nodes](../develop/network/private-chain/private-chain2.md)

Refer to the instructions from above links to set up your private chain and withdraw NEO and GAS from genesis block.

## Preparing a wallet file

Now let's create a new wallet file used for deploying smart contracts:

1. Create a new wallet file named 0.json and copy the default address for later use.
2. Open the wallet where you have withdrawn NEO and GAS from genesis block, transfer all the assets in the wallet to 0.json and wait for the transaction to be confirmed.
3. Open 0.json to check if the assets are received.

15 changes: 15 additions & 0 deletions docs/n3/gettingstarted/prerequisites.md
@@ -0,0 +1,15 @@
# Before You Begin

In this tutorial, we will work you through an example of how to release an NEP17 asset on Neo blockchain, which includes the tasks of setting up and configuring the development environment, compiling, deploying and invoking the smart contract on a private Neo chain.

## System environment

You are recommended to run Neo-CLI in the following environments that we have tested:

- Windows 10
- Ubuntu 20.04
- macOS Big Sur/version 11.1

### Download Neo-CLI

Refer to [Neo-CLI Setup](../node/cli/setup.md) to download and install Neo-CLI package from GitHub.
5 changes: 5 additions & 0 deletions docs/n3/migration/_category_.json
@@ -0,0 +1,5 @@
{
"label": "Cross-chain Migration",
"position": 10
}

Binary file added docs/n3/migration/assets/Picture1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture10.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture11.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/n3/migration/assets/Picture8.png
Binary file added docs/n3/migration/assets/Picture9.png
Binary file added docs/n3/migration/assets/history.png

0 comments on commit 2a4ccd6

Please sign in to comment.