From 1820d6e92e3ff508d0849ce154d73efb9edbfc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Fri, 14 Jun 2024 13:08:34 +0800 Subject: [PATCH 01/18] SupportedStandards --- docs/n3/develop/write/basics.md | 2 +- docs/n3/develop/write/difference.md | 4 ++-- docs/n3/develop/write/nep11.md | 4 ++-- docs/n3/develop/write/nep17.md | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/n3/develop/write/basics.md b/docs/n3/develop/write/basics.md index a037f9e..b9bbec5 100644 --- a/docs/n3/develop/write/basics.md +++ b/docs/n3/develop/write/basics.md @@ -196,7 +196,7 @@ You can declare more features: [ContractSourceCode("https://github.com/neo-project/neo-devpack-dotnet/tree/master/examples/")] [ContractVersion("0.0.1")] [DisplayName("SampleNep17Token")] -[SupportedStandards("NEP-17")] +[SupportedStandards(NepStandard.Nep17)] [ContractPermission("*", "onNEP17Payment")] [ContractTrust("0x0a0b00ff00ff00ff00ff00ff00ff00ff00ff00a4")] [ManifestExtra("WebSite", "https://neo.org")] diff --git a/docs/n3/develop/write/difference.md b/docs/n3/develop/write/difference.md index 54d2a14..95fb743 100644 --- a/docs/n3/develop/write/difference.md +++ b/docs/n3/develop/write/difference.md @@ -57,9 +57,9 @@ using System; | | Neo Legacy | Neo N3 | | ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| Contract info | You need to fill in contract information such as the name, author, email, etc. when deploying the contract. | Add the contract features to the contract file, written as [C# Features](https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/attributes/), for example:
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "dev@neo.org")]
[ContractTrust("\*")]
[ContractPermission("\*", "\*")]
[SupportedStandards("NEP-17")]
[ManifestExtra("Description", "This is a contract example")]
public class Contract1 : SmartContract | +| Contract info | You need to fill in contract information such as the name, author, email, etc. when deploying the contract. | Add the contract features to the contract file, written as [C# Features](https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/attributes/), for example:
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "dev@neo.org")]
[ContractTrust("\*")]
[ContractPermission("\*", "\*")]
[SupportedStandards(NepStandard.Nep17)]
[ManifestExtra("Description", "This is a contract example")]
public class Contract1 : SmartContract | | Contract function | When deploying a contract, you need to declare contract features such as whether to use storage, whether it can be called dynamically, and whether to accept NEP-5 assets. | All contracts can use the storage and dynamic calls by default. You can implement the OnNEP17Payment method to accept NEP-17 assets and implement the OnNEP11Payment method to accept NEP-11 (NFT standard) assets. | -| Declare support for NEP | Code example:
public static string[] SupportedStandards()
{
string[] result = { "NEP-5", "NEP-7", "NEP-10" };
return result;
} | Directly add the feature to the contract class name `[SupportedStandards("NEP-17")]` | +| Declare support for NEP | Code example:
public static string[] SupportedStandards()
{
string[] result = { "NEP-5", "NEP-7", "NEP-10" };
return result;
} | Directly add the feature to the contract class name `[SupportedStandards(NepStandard.Nep17)]` | ### Declaration of static variables diff --git a/docs/n3/develop/write/nep11.md b/docs/n3/develop/write/nep11.md index d48dbe9..846bc66 100644 --- a/docs/n3/develop/write/nep11.md +++ b/docs/n3/develop/write/nep11.md @@ -74,7 +74,7 @@ using System; namespace Contract1 { - [SupportedStandards("NEP-11")] + [SupportedStandards(NepStandard.Nep11)] public class Contract1 : Nep11Token { //TODO: Replace it with your own address. @@ -155,7 +155,7 @@ The base class `Nep11Token` also provides the following methods and events: ### Compatibility check -Compatibility checks will be activated for any contract that includes the `[SupportedStandards("NEP-17")]` or `[SupportedStandards("NEP-11")]` attribute. +Compatibility checks will be activated for any contract that includes the `[SupportedStandards(NepStandard.Nep17)]` or `[SupportedStandards(NepStandard.Nep11)]` 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 diff --git a/docs/n3/develop/write/nep17.md b/docs/n3/develop/write/nep17.md index 4a98b73..889785d 100644 --- a/docs/n3/develop/write/nep17.md +++ b/docs/n3/develop/write/nep17.md @@ -286,7 +286,7 @@ The name method is moved to the manifest file, and you need to add `[DisplayName [ContractAuthor("core-dev", "dev@neo.org")] [ContractEmail("dev@neo.org")] [ContractDescription("This is a NEP17 example")] -[SupportedStandards("NEP-17")] +[SupportedStandards(NepStandard.Nep17)] public class NEP17 : Nep17Token { public override string Symbol { [Safe] get => "EXAMPLE"; } @@ -309,6 +309,6 @@ The ability of the contract to receive assets has been changed from a fixed cons ### Compatibility check -Compatibility checks will be activated for any contract that includes the `[SupportedStandards("NEP-17")]` or `[SupportedStandards("NEP-11")]` attribute. +Compatibility checks will be activated for any contract that includes the `[SupportedStandards(NepStandard.Nep17)]`, `[SupportedStandards(NepStandard.Nep11)]` or `[SupportedStandards(NepStandard.Nep24)]` 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. From 7f8e7f998dce1f6424100adf809cf00fc4d332a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Fri, 14 Jun 2024 13:34:25 +0800 Subject: [PATCH 02/18] remove InitialValue --- docs/n3/develop/write/basics.md | 10 ++++------ docs/n3/develop/write/difference.md | 7 +++---- docs/n3/develop/write/nep11.md | 3 +-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/n3/develop/write/basics.md b/docs/n3/develop/write/basics.md index b9bbec5..6c25f7b 100644 --- a/docs/n3/develop/write/basics.md +++ b/docs/n3/develop/write/basics.md @@ -24,8 +24,7 @@ namespace Helloworld public class Contract1 : SmartContract { //TODO: Replace it with your own address. - [InitialValue("NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB", ContractParameterType.Hash160)] - static readonly UInt160 Owner = default; + static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB"; private static bool IsOwner() => Runtime.CheckWitness(Owner); @@ -69,8 +68,7 @@ Inside the contract class, the property defined with `static readonly` or `const ```cs // Represents onwner of this contract, which is a fixed address. Usually should be the contract creator -[InitialValue("NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB", ContractParameterType.Hash160)] -static readonly UInt160 Owner = default; +static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB"; // A constant number private const ulong factor = 100000000; @@ -197,7 +195,7 @@ You can declare more features: [ContractVersion("0.0.1")] [DisplayName("SampleNep17Token")] [SupportedStandards(NepStandard.Nep17)] -[ContractPermission("*", "onNEP17Payment")] +[ContractPermission(Permission.Any, "onNEP17Payment")] [ContractTrust("0x0a0b00ff00ff00ff00ff00ff00ff00ff00ff00a4")] [ManifestExtra("WebSite", "https://neo.org")] public class Contract1 : SmartContract @@ -210,7 +208,7 @@ public class Contract1 : SmartContract ``` - `DisplayName`: The name of the nef and manifest.json files generated by the compiler, and the DisplayName is also written to the name field of manifest.json. -- `SupportedStandards`: The NEP standards the contract conform to, such as NEP-17, a token standard on Neo. +- `SupportedStandards`: The NEP standards the contract conform to, such as `NepStandard.Nep17`, a token standard on Neo. - `ContractPermission` : The permission requested by the contract, and `ContractTrust` indicates which contracts trust the contract to call itself. See [invocation-permission](../deploy/invoke.md#invocation-permission). - `ContractAuthor`: The author field, which can be filled with the author's name and email address. It will output to the extra json object in manifest.json. - `ContractEmail`: The email field. It will be output to the extra json object in manifest.json. diff --git a/docs/n3/develop/write/difference.md b/docs/n3/develop/write/difference.md index 95fb743..062c424 100644 --- a/docs/n3/develop/write/difference.md +++ b/docs/n3/develop/write/difference.md @@ -57,9 +57,9 @@ using System; | | Neo Legacy | Neo N3 | | ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| Contract info | You need to fill in contract information such as the name, author, email, etc. when deploying the contract. | Add the contract features to the contract file, written as [C# Features](https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/attributes/), for example:
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "dev@neo.org")]
[ContractTrust("\*")]
[ContractPermission("\*", "\*")]
[SupportedStandards(NepStandard.Nep17)]
[ManifestExtra("Description", "This is a contract example")]
public class Contract1 : SmartContract | +| Contract info | You need to fill in contract information such as the name, author, email, etc. when deploying the contract. | Add the contract features to the contract file, written as [C# Features](https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/attributes/), for example:
[ContractAuthor("core-dev", "dev@neo.org")]
[ContractEmail("dev@neo.org")]
[ContractDescription("A sample NEP-17 token")]
[ContractPermission(Permission.Any, Method.Any)]
[ContractTrust(Permission.Any)]
[SupportedStandards(NepStandard.Nep17)]
public class Contract1 : SmartContract | | Contract function | When deploying a contract, you need to declare contract features such as whether to use storage, whether it can be called dynamically, and whether to accept NEP-5 assets. | All contracts can use the storage and dynamic calls by default. You can implement the OnNEP17Payment method to accept NEP-17 assets and implement the OnNEP11Payment method to accept NEP-11 (NFT standard) assets. | -| Declare support for NEP | Code example:
public static string[] SupportedStandards()
{
string[] result = { "NEP-5", "NEP-7", "NEP-10" };
return result;
} | Directly add the feature to the contract class name `[SupportedStandards(NepStandard.Nep17)]` | +| Declare support for NEP | Code example:
public static string[] SupportedStandards()
{
string[] result = { "NEP-11", "NEP-17", "NEP-24" };
return result;
} | Directly add the feature to the contract class name `[SupportedStandards(NepStandard.Nep17)]` | ### Declaration of static variables @@ -72,8 +72,7 @@ private static readonly byte[] InitialOwnerScriptHash = "AJhZmdHxW44FWMiMxD5bTiF Neo N3 ```cs -[InitialValue("NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB", ContractParameterType.Hash160)] -static readonly UInt160 Owner = default; +static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB"; ``` ### Methods and Events diff --git a/docs/n3/develop/write/nep11.md b/docs/n3/develop/write/nep11.md index 846bc66..0185d67 100644 --- a/docs/n3/develop/write/nep11.md +++ b/docs/n3/develop/write/nep11.md @@ -78,8 +78,7 @@ namespace Contract1 public class Contract1 : Nep11Token { //TODO: Replace it with your own address. - [InitialValue("NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB", ContractParameterType.Hash160)] - static readonly UInt160 Owner = default; + static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB"; private static bool IsOwner() => Runtime.CheckWitness(Owner); From b26b84a81154a7a23d1aeab372516179fac2f654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Fri, 14 Jun 2024 13:42:22 +0800 Subject: [PATCH 03/18] Update basics.md --- docs/n3/develop/write/basics.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/n3/develop/write/basics.md b/docs/n3/develop/write/basics.md index 6c25f7b..e497ef8 100644 --- a/docs/n3/develop/write/basics.md +++ b/docs/n3/develop/write/basics.md @@ -222,7 +222,9 @@ The generated manifest is as follows: ```json { "name": "SampleNep17Token", - "supportedstandards": [], + "supportedstandards": [ + "NEP-17" + ], "abi": { }, "permissions": [ From 56a0c0242db4d4a0de6fda6a0d90dcc921ddb46f Mon Sep 17 00:00:00 2001 From: Michael Bucher Date: Tue, 30 Jul 2024 22:40:41 +0200 Subject: [PATCH 04/18] Update neow3j tutorials for neow3j version 3.23.0 --- .../assets/neow3j-padded.png | Bin .../index.md | 16 ++++++---------- .../assets/neow3j-padded.png | Bin .../index.md | 16 ++++++---------- .../assets/neow3j-padded.png | Bin .../index.md | 10 ++++------ .../assets/neow3j-padded.png | Bin .../index.md | 5 +---- 8 files changed, 17 insertions(+), 30 deletions(-) rename tutorials/{2023-10-17-neow3j-sdk-quickstart => 2024-07-31-neow3j-nep11}/assets/neow3j-padded.png (100%) rename tutorials/{2024-02-27-neow3j-nep11 => 2024-07-31-neow3j-nep11}/index.md (98%) rename tutorials/{2023-10-17-neow3j-smart-contract-quickstart => 2024-07-31-neow3j-nep17}/assets/neow3j-padded.png (100%) rename tutorials/{2024-02-27-neow3j-nep17 => 2024-07-31-neow3j-nep17}/index.md (96%) rename tutorials/{2024-02-27-neow3j-nep11 => 2024-07-31-neow3j-sdk-quickstart}/assets/neow3j-padded.png (100%) rename tutorials/{2023-10-17-neow3j-sdk-quickstart => 2024-07-31-neow3j-sdk-quickstart}/index.md (96%) rename tutorials/{2024-02-27-neow3j-nep17 => 2024-07-31-neow3j-smart-contract-quickstart}/assets/neow3j-padded.png (100%) rename tutorials/{2023-10-17-neow3j-smart-contract-quickstart => 2024-07-31-neow3j-smart-contract-quickstart}/index.md (96%) diff --git a/tutorials/2023-10-17-neow3j-sdk-quickstart/assets/neow3j-padded.png b/tutorials/2024-07-31-neow3j-nep11/assets/neow3j-padded.png similarity index 100% rename from tutorials/2023-10-17-neow3j-sdk-quickstart/assets/neow3j-padded.png rename to tutorials/2024-07-31-neow3j-nep11/assets/neow3j-padded.png diff --git a/tutorials/2024-02-27-neow3j-nep11/index.md b/tutorials/2024-07-31-neow3j-nep11/index.md similarity index 98% rename from tutorials/2024-02-27-neow3j-nep11/index.md rename to tutorials/2024-07-31-neow3j-nep11/index.md index 739168d..fa741e3 100644 --- a/tutorials/2024-02-27-neow3j-nep11/index.md +++ b/tutorials/2024-07-31-neow3j-nep11/index.md @@ -6,13 +6,13 @@ author: AxLabs tags: ["NEP-11", "JAVA", "NEOW3J"] skill: beginner image: "./assets/neow3j-padded.png" -source: "https://github.com/neow3j/neow3j-examples-java/blob/7d462fab0dc27f7472b0cacf4beba6c08a7682e8/src/main/java/io/neow3j/examples/contractdevelopment/contracts/NonFungibleToken.java" +source: "https://github.com/neow3j/neow3j-examples-java/blob/13b72b6ac85a2be305827b78bd973092e21c8c9f/src/main/java/io/neow3j/examples/contractdevelopment/contracts/NonFungibleToken.java" sidebar: true ---
neow3j -

neow3j v3.22.1

+

neow3j v3.23.0

Neow3j is a development toolkit that provides easy and reliable tools to build Neo dApps and Smart Contracts using the @@ -67,7 +67,6 @@ import io.neow3j.devpack.annotations.Safe; import io.neow3j.devpack.annotations.SupportedStandard; import io.neow3j.devpack.constants.CallFlags; import io.neow3j.devpack.constants.FindOptions; -import io.neow3j.devpack.constants.NativeContract; import io.neow3j.devpack.constants.NeoStandard; import io.neow3j.devpack.contracts.ContractManagement; import io.neow3j.devpack.events.Event3Args; @@ -76,7 +75,7 @@ import io.neow3j.devpack.events.Event4Args; @DisplayName("FurryFriends") @ManifestExtra(key = "author", value = "AxLabs") @SupportedStandard(neoStandard = NeoStandard.NEP_11) -@Permission(nativeContract = NativeContract.ContractManagement) +@Permission(contract = "*") public class NonFungibleToken { // Alice's address @@ -382,7 +381,6 @@ import io.neow3j.devpack.annotations.Safe; import io.neow3j.devpack.annotations.SupportedStandard; import io.neow3j.devpack.constants.CallFlags; import io.neow3j.devpack.constants.FindOptions; -import io.neow3j.devpack.constants.NativeContract; import io.neow3j.devpack.constants.NeoStandard; import io.neow3j.devpack.contracts.ContractManagement; import io.neow3j.devpack.events.Event3Args; @@ -412,16 +410,14 @@ string value. _`Permission`_ Specifies, which third-party contracts and methods the smart contract is allowed to call. By default (i.e., if no permission annotation is set), the contract is not allowed to call any contract. Use `contract = ` and `methods = ` to -specify, respectively, which contracts and methods are allowed. - -_For example, if you want to allow transferring NEO tokens from the contract, you can add the annotation -`@Permission(nativeContract = NativeContract.NeoToken, methods = "transfer")`._ +specify, respectively, which contracts and methods are allowed. The permission in this example means that any contract +and all its methods are allowed. ```java @DisplayName("FurryFriends") @ManifestExtra(key = "author", value = "AxLabs") @SupportedStandard(neoStandard = NeoStandard.NEP_11) -@Permission(nativeContract = NativeContract.ContractManagement) +@Permission(contract = "*") public class NonFungibleToken { ``` diff --git a/tutorials/2023-10-17-neow3j-smart-contract-quickstart/assets/neow3j-padded.png b/tutorials/2024-07-31-neow3j-nep17/assets/neow3j-padded.png similarity index 100% rename from tutorials/2023-10-17-neow3j-smart-contract-quickstart/assets/neow3j-padded.png rename to tutorials/2024-07-31-neow3j-nep17/assets/neow3j-padded.png diff --git a/tutorials/2024-02-27-neow3j-nep17/index.md b/tutorials/2024-07-31-neow3j-nep17/index.md similarity index 96% rename from tutorials/2024-02-27-neow3j-nep17/index.md rename to tutorials/2024-07-31-neow3j-nep17/index.md index fbd871d..7da82e3 100644 --- a/tutorials/2024-02-27-neow3j-nep17/index.md +++ b/tutorials/2024-07-31-neow3j-nep17/index.md @@ -6,13 +6,13 @@ author: AxLabs tags: ["NEP-17", "JAVA", "NEOW3J"] skill: beginner image: "./assets/neow3j-padded.png" -source: "https://github.com/neow3j/neow3j-examples-java/blob/7d462fab0dc27f7472b0cacf4beba6c08a7682e8/src/main/java/io/neow3j/examples/contractdevelopment/contracts/FungibleToken.java" +source: "https://github.com/neow3j/neow3j-examples-java/blob/13b72b6ac85a2be305827b78bd973092e21c8c9f/src/main/java/io/neow3j/examples/contractdevelopment/contracts/FungibleToken.java" sidebar: true ---
neow3j -

neow3j v3.22.1

+

neow3j v3.23.0

Neow3j is a development toolkit that provides easy and reliable tools to build Neo dApps and Smart Contracts using the @@ -51,7 +51,6 @@ import io.neow3j.devpack.annotations.Permission; import io.neow3j.devpack.annotations.Safe; import io.neow3j.devpack.annotations.SupportedStandard; import io.neow3j.devpack.constants.CallFlags; -import io.neow3j.devpack.constants.NativeContract; import io.neow3j.devpack.constants.NeoStandard; import io.neow3j.devpack.contracts.ContractManagement; import io.neow3j.devpack.events.Event3Args; @@ -60,7 +59,7 @@ import io.neow3j.devpack.events.Event3Args; @ManifestExtra(key = "name", value = "AxLabsToken") @ManifestExtra(key = "author", value = "AxLabs") @SupportedStandard(neoStandard = NeoStandard.NEP_17) -@Permission(nativeContract = NativeContract.ContractManagement) +@Permission(contract = "*") public class FungibleToken { static final int contractMapPrefix = 0; @@ -220,7 +219,6 @@ import io.neow3j.devpack.annotations.Permission; import io.neow3j.devpack.annotations.Safe; import io.neow3j.devpack.annotations.SupportedStandard; import io.neow3j.devpack.constants.CallFlags; -import io.neow3j.devpack.constants.NativeContract; import io.neow3j.devpack.constants.NeoStandard; import io.neow3j.devpack.contracts.ContractManagement; import io.neow3j.devpack.events.Event3Args; @@ -250,17 +248,15 @@ _`@Permission`_ Specifies, which third-party contracts and methods the smart contract is allowed to call. By default (i.e., if no permission annotation is set), the contract is not allowed to call any contract. Use `contract = ` and `methods = ` to -specify, respectively, which contracts and methods are allowed. - -_For example, if you want to allow transferring NEO tokens from the contract, you can add the annotation -`@Permission(nativeContract = NativeContract.NeoToken, methods = "transfer")`._ +specify, respectively, which contracts and methods are allowed. The permission in this example means that any contract +and all its methods are allowed. ```java @DisplayName("AxLabsToken") @ManifestExtra(key = "name", value = "AxLabsToken") @ManifestExtra(key = "author", value = "AxLabs") @SupportedStandard(neoStandard = NeoStandard.NEP_17) -@Permission(nativeContract = NativeContract.ContractManagement) +@Permission(contract = "*") public class FungibleToken { ``` diff --git a/tutorials/2024-02-27-neow3j-nep11/assets/neow3j-padded.png b/tutorials/2024-07-31-neow3j-sdk-quickstart/assets/neow3j-padded.png similarity index 100% rename from tutorials/2024-02-27-neow3j-nep11/assets/neow3j-padded.png rename to tutorials/2024-07-31-neow3j-sdk-quickstart/assets/neow3j-padded.png diff --git a/tutorials/2023-10-17-neow3j-sdk-quickstart/index.md b/tutorials/2024-07-31-neow3j-sdk-quickstart/index.md similarity index 96% rename from tutorials/2023-10-17-neow3j-sdk-quickstart/index.md rename to tutorials/2024-07-31-neow3j-sdk-quickstart/index.md index 35acdf1..753bd94 100644 --- a/tutorials/2023-10-17-neow3j-sdk-quickstart/index.md +++ b/tutorials/2024-07-31-neow3j-sdk-quickstart/index.md @@ -12,7 +12,7 @@ sidebar: true
neow3j -

neow3j v3.22.1

+

neow3j v3.23.0

## 1. Introduction @@ -27,8 +27,7 @@ information on neow3j and the technical documentation. __Java__ -DApp development in Java requires a Java SDK of at least version 8. Checkout [Adoptium](https://adoptium.net/) -for Java OpenJDK downloads. +DApp development in Java requires a Java SDK of at least version 8. Checkout [Adoptium](https://adoptium.net/) for Java OpenJDK downloads. __Neo-Express__ @@ -46,9 +45,8 @@ development on Neo. If you use VS Code make sure to install the [Neo Blockchain Toolkit](https://marketplace.visualstudio.com/items?itemName=ngd-seattle.neo-blockchain-toolkit) extension. It supports an easy setup of private blockchains, provides functionality to quickly fund an address, an -in-editor block explorer and much more. To get familiar with the Blockchain Toolkit checkout the quickstart tutorials -[here](https://ngdenterprise.com/neo-tutorials/quickstart1.html). For optimal Java support in VS Code we recommend -using the [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack). +in-editor block explorer and much more. For optimal Java support in VS Code we recommend using the +[Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack). ### Code diff --git a/tutorials/2024-02-27-neow3j-nep17/assets/neow3j-padded.png b/tutorials/2024-07-31-neow3j-smart-contract-quickstart/assets/neow3j-padded.png similarity index 100% rename from tutorials/2024-02-27-neow3j-nep17/assets/neow3j-padded.png rename to tutorials/2024-07-31-neow3j-smart-contract-quickstart/assets/neow3j-padded.png diff --git a/tutorials/2023-10-17-neow3j-smart-contract-quickstart/index.md b/tutorials/2024-07-31-neow3j-smart-contract-quickstart/index.md similarity index 96% rename from tutorials/2023-10-17-neow3j-smart-contract-quickstart/index.md rename to tutorials/2024-07-31-neow3j-smart-contract-quickstart/index.md index 48bd2dc..24d9cdd 100644 --- a/tutorials/2023-10-17-neow3j-smart-contract-quickstart/index.md +++ b/tutorials/2024-07-31-neow3j-smart-contract-quickstart/index.md @@ -12,7 +12,7 @@ sidebar: true
neow3j -

neow3j v3.22.1

+

neow3j v3.23.0

## 1. Introduction @@ -45,9 +45,6 @@ development on Neo. If you use VS Code make sure to install the [Neo Blockchain Toolkit](https://marketplace.visualstudio.com/items?itemName=ngd-seattle.neo-blockchain-toolkit) extension. It supports contract debugging, easy setup of private blockchains, and an in-editor block explorer. -To get familiar with the Blockchain Toolkit checkout the quickstart tutorials -[here](https://ngdenterprise.com/neo-tutorials/quickstart1.html) (the tutorials use C# as the smart contract -language). For optimal Java support in VS Code we recommend using the [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack). From 118baccf2df5c49a818be14fc666db90af2dd5e2 Mon Sep 17 00:00:00 2001 From: Michael Bucher Date: Tue, 30 Jul 2024 22:51:26 +0200 Subject: [PATCH 05/18] (minor) Fix text format in neow3j tutorials --- tutorials/2024-07-31-neow3j-nep11/index.md | 103 +++++------------- tutorials/2024-07-31-neow3j-nep17/index.md | 88 ++++----------- .../2024-07-31-neow3j-sdk-quickstart/index.md | 72 +++--------- .../index.md | 74 +++---------- 4 files changed, 86 insertions(+), 251 deletions(-) diff --git a/tutorials/2024-07-31-neow3j-nep11/index.md b/tutorials/2024-07-31-neow3j-nep11/index.md index fa741e3..d956934 100644 --- a/tutorials/2024-07-31-neow3j-nep11/index.md +++ b/tutorials/2024-07-31-neow3j-nep11/index.md @@ -15,19 +15,15 @@ sidebar: true

neow3j v3.23.0

-Neow3j is a development toolkit that provides easy and reliable tools to build Neo dApps and Smart Contracts using the -Java platform (Java, Kotlin, Android). Check out [neow3j.io](https://neow3j.io) for more detailed information on neow3j -and the technical documentation. +Neow3j is a development toolkit that provides easy and reliable tools to build Neo dApps and Smart Contracts using the Java platform (Java, Kotlin, Android). Check out [neow3j.io](https://neow3j.io) for more detailed information on neow3j and the technical documentation. ## 1. Setup -If you haven't already set up your environment to use the neow3j library, you can check out our tutorial about setting -up a neow3j project [here](/tutorials/neow3j-smart-contract-quickstart). +If you haven't already set up your environment to use the neow3j library, you can check out our tutorial about setting up a neow3j project [here](/tutorials/neow3j-smart-contract-quickstart). ## 2. NEP-11 Overview -The NEP-11 is the non-fungible token (NFT) standard on Neo N3. Have a look at its official documentation -[here](https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki). +The NEP-11 is the non-fungible token (NFT) standard on Neo N3. Have a look at its official documentation [here](https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki). ## 3. Example NEP-11 Contract @@ -39,9 +35,7 @@ This example contract supports **indivisible** NFTs (i.e., `decimals` is equal t
-The NEP-11 standard also describes what methods are required if divisible NTFs should be supported. Some of the methods -required for divisible NFTS deviate from the ones discussed here. Check out the documentation of the NEP-11 standard -[here](https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki) for more details. +The NEP-11 standard also describes what methods are required if divisible NTFs should be supported. Some of the methods required for divisible NFTS deviate from the ones discussed here. Check out the documentation of the NEP-11 standard [here](https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki) for more details. ::: @@ -355,9 +349,7 @@ public class NonFungibleToken { ### Imports -The imports show the neow3j devpack classes that are used in the example contract. Check out neow3j devpack's -[javadoc](https://javadoc.io/doc/io.neow3j/devpack/latest/index.html) for a full overview of classes and methods that -are supported. +The imports show the neow3j devpack classes that are used in the example contract. Check out neow3j devpack's [javadoc](https://javadoc.io/doc/io.neow3j/devpack/latest/index.html) for a full overview of classes and methods that are supported. ```java package io.neow3j.examples.contractdevelopment.contracts; @@ -389,8 +381,7 @@ import io.neow3j.devpack.events.Event4Args; ### Contract-specific Information -Annotations on top of the smart contract's class represent contract-specific information. The following annotations are -used in the example contract: +Annotations on top of the smart contract's class represent contract-specific information. The following annotations are used in the example contract: _`@DisplayName`_ @@ -398,20 +389,14 @@ Specifies the contract's name. If this annotation is not present, the class name _`@ManifestExtra`_ -Adds the provided key-value pair information in the manifest's `extra` field. You can also use `@ManifestsExtras` to -gather multiple `@ManifestExtra` annotations (results in the same as when using single `@ManifestExtra` annotations). +Adds the provided key-value pair information in the manifest's `extra` field. You can also use `@ManifestsExtras` to gather multiple `@ManifestExtra` annotations (results in the same as when using single `@ManifestExtra` annotations). _`@SupportedStandard`_ -Sets the `supportedStandards` field in the manifest. You can use `neoStandard = ` with the enum `NeoStandard` to use an -official standard (see [here](https://github.com/neo-project/proposals#readme)), or `customStandard = ` with a custom -string value. +Sets the `supportedStandards` field in the manifest. You can use `neoStandard = ` with the enum `NeoStandard` to use an official standard (see [here](https://github.com/neo-project/proposals#readme)), or `customStandard = ` with a custom string value. _`Permission`_ -Specifies, which third-party contracts and methods the smart contract is allowed to call. By default (i.e., if no -permission annotation is set), the contract is not allowed to call any contract. Use `contract = ` and `methods = ` to -specify, respectively, which contracts and methods are allowed. The permission in this example means that any contract -and all its methods are allowed. +Specifies, which third-party contracts and methods the smart contract is allowed to call. By default (i.e., if no permission annotation is set), the contract is not allowed to call any contract. Use `contract = ` and `methods = ` to specify, respectively, which contracts and methods are allowed. The permission in this example means that any contract and all its methods are allowed. ```java @DisplayName("FurryFriends") @@ -423,21 +408,16 @@ public class NonFungibleToken { ### Constants -You can set a constant value for the contract by using `final` variables. These values are always loaded when the -contract is called and cannot be changed once the contract is deployed. If a final value does not include a method call -(e.g., raw types, or a final `String` value, such as "name"), then these values are inlined during compilation. +You can set a constant value for the contract by using `final` variables. These values are always loaded when the contract is called and cannot be changed once the contract is deployed. If a final value does not include a method call (e.g., raw types, or a final `String` value, such as "name"), then these values are inlined during compilation. :::note -All contract constants and all methods must be `static` (since the object-orientation of the JVM is different on the -NeoVM). +All contract constants and all methods must be `static` (since the object-orientation of the JVM is different on the NeoVM). ::: :::tip -The contract owner of this example contract is fixed (i.e., it is a `final` variable). If you intend to provide a way to -change such a variable, you should not store it as a `final` variable. Rather, you would store it as a value in the -storage, which provides the possibility to be modified through a method. +The contract owner of this example contract is fixed (i.e., it is a `final` variable). If you intend to provide a way to change such a variable, you should not store it as a `final` variable. Rather, you would store it as a value in the storage, which provides the possibility to be modified through a method. ::: @@ -466,9 +446,7 @@ static final String propTokenURI = "tokenURI"; ### Deploy -Once a deployment transaction is made (containing the contract and other parameters), the contract data is first stored -on the blockchain and then the native contract `ContractManagement` calls the smart contract's `deploy()` method. In -neow3j, that method is marked with the annotation `@OnDeployment`. +Once a deployment transaction is made (containing the contract and other parameters), the contract data is first stored on the blockchain and then the native contract `ContractManagement` calls the smart contract's `deploy()` method. In neow3j, that method is marked with the annotation `@OnDeployment`. ```java @OnDeployment @@ -482,15 +460,11 @@ public static void deploy(Object data, boolean update) { ### Update and Destroy -In order to update the contract, the following method first checks that the contract owner witnessed the transaction and -then the native `ContractManagement.update()` method is called. When updating a smart contract, you can change the smart -contract's code and its manifest. This means that you can update how the contract programmatically manages its storage -context. +In order to update the contract, the following method first checks that the contract owner witnessed the transaction and then the native `ContractManagement.update()` method is called. When updating a smart contract, you can change the smart contract's code and its manifest. This means that you can update how the contract programmatically manages its storage context. :::note -Additionally to changing the smart contract's script and manifest, the method `ContractManagement.update()` eventually -calls the smart contract's `deploy()` method (shown above) with the boolean `update` set to true. +Additionally to changing the smart contract's script and manifest, the method `ContractManagement.update()` eventually calls the smart contract's `deploy()` method (shown above) with the boolean `update` set to true. ::: @@ -503,14 +477,11 @@ public static void update(ByteString script, String manifest) throws Exception { } ``` -The example contract also provides the option to destroy the smart contract. As well as the `update()` method, it first -verifies that the contract owner witnessed the transaction and then calls the method `ContractManagement.destroy()` -method. +The example contract also provides the option to destroy the smart contract. As well as the `update()` method, it first verifies that the contract owner witnessed the transaction and then calls the method `ContractManagement.destroy()` method. :::caution -When the native method `ContractManagement.destroy()` is called from a smart contract, the whole smart contract's -storage context is erased, and the contract can no longer be used. +When the native method `ContractManagement.destroy()` is called from a smart contract, the whole smart contract's storage context is erased, and the contract can no longer be used. ::: @@ -525,9 +496,7 @@ public static void destroy() throws Exception { ### NEP-11 Methods -The required NEP-11 methods are implemented as follows. If a method does not change the state of the contract (i.e., it -is just used for reading), it can be annotated with the `@Safe` annotation. Out of the required NEP-11 methods, only the -`transfer()` method should be writing to the contract's storage and, thus, is not annotated as safe. +The required NEP-11 methods are implemented as follows. If a method does not change the state of the contract (i.e., it is just used for reading), it can be annotated with the `@Safe` annotation. Out of the required NEP-11 methods, only the `transfer()` method should be writing to the contract's storage and, thus, is not annotated as safe. ```java @Safe @@ -593,9 +562,7 @@ public static boolean transfer(Hash160 to, ByteString tokenId, Object data) thro ### Non-divisible NEP-11 Methods -The NEP-11 standard specifies non-divisible as well as divisible NFT smart contracts. Since this smart contract is -indivisible (i.e., its decimals are 0), it is required to implement a specific method `ownerOf` for it. It returns the -script hash of the owner the token with the specified token id. +The NEP-11 standard specifies non-divisible as well as divisible NFT smart contracts. Since this smart contract is indivisible (i.e., its decimals are 0), it is required to implement a specific method `ownerOf` for it. It returns the script hash of the owner the token with the specified token id. ```java @Safe @@ -613,11 +580,7 @@ public static Hash160 ownerOf(ByteString tokenId) throws Exception { ### NEP-11 Optional Methods -The NEP-11 standard describes two optional methods called `tokens()` and `properties()`. Meaning that if methods with -these names and parameters are implemented, they must follow the standard. Below you can see the implementation of these -two methods. The `tokens()` method iterates through the `registryMap` and returns an `Iterator` based on the key-value -pairs that are found in the registry. The `properties()` method returns a map of the provided token's properties stored -in the contract's storage. This includes its name, and if present its description, image, and URI. +The NEP-11 standard describes two optional methods called `tokens()` and `properties()`. Meaning that if methods with these names and parameters are implemented, they must follow the standard. Below you can see the implementation of these two methods. The `tokens()` method iterates through the `registryMap` and returns an `Iterator` based on the key-value pairs that are found in the registry. The `properties()` method returns a map of the provided token's properties stored in the contract's storage. This includes its name, and if present its description, image, and URI. ```java @Safe @@ -657,9 +620,7 @@ public static Map properties(ByteString tokenId) throws Exceptio ### Events -The NEP-11 standard requires an event `Transfer` that contains the values `from`, `to`, `amount`, and `tokenId`. For -this, the class `Event4Args` can be used with the annotation `@DisplayName` to set the event's name that will be shown -in the manifest and notifications when it has been fired. +The NEP-11 standard requires an event `Transfer` that contains the values `from`, `to`, `amount`, and `tokenId`. For this, the class `Event4Args` can be used with the annotation `@DisplayName` to set the event's name that will be shown in the manifest and notifications when it has been fired. ```java @DisplayName("Transfer") @@ -678,13 +639,9 @@ The example contract contains some custom methods, that are not specified in the The method `contractOwner()` simply returns the script hash of the contract owner. -The method `mint()` can be invoked by the contract owner in order to mint new NFT tokens. It stores the tokenId in the -`registryMap`, its properties in the `propertiesMap`, and its owner in the `ownerMap`. Further, it increases the owner's -balance, and the total supply by 1, before it fires the `Transfer` event. +The method `mint()` can be invoked by the contract owner in order to mint new NFT tokens. It stores the tokenId in the `registryMap`, its properties in the `propertiesMap`, and its owner in the `ownerMap`. Further, it increases the owner's balance, and the total supply by 1, before it fires the `Transfer` event. -The method `burn()` can be invoked by the owner of a token. It deletes all information about the token and updates the -balance and total supply accordingly. If the intent of burning a token need not require the storage to be freed, the -token could also just be sent to a *burner address*. +The method `burn()` can be invoked by the owner of a token. It deletes all information about the token and updates the balance and total supply accordingly. If the intent of burning a token need not require the storage to be freed, the token could also just be sent to a *burner address*. ```java @Safe @@ -757,8 +714,7 @@ public static void burn(ByteString tokenId) throws Exception { ### Private Helper Methods -Private methods can be used to simplify and make the smart contract more readable. The following private methods are -used in the NEP-11 example contract. +Private methods can be used to simplify and make the smart contract more readable. The following private methods are used in the NEP-11 example contract. ```java private static int getBalance(StorageContext ctx, Hash160 owner) { @@ -792,9 +748,7 @@ private static byte[] createTokensOfPrefix(Hash160 owner) { ## 5. Compile the Contract -The contract can be compiled using the gradle plugin. First, set the `className` in the file `gradle.build` to the -contract's class name. Then, the gradle task `neow3jCompile` can be executed from the project's root path to compile the -contract. +The contract can be compiled using the gradle plugin. First, set the `className` in the file `gradle.build` to the contract's class name. Then, the gradle task `neow3jCompile` can be executed from the project's root path to compile the contract. ```bash ./gradlew neow3jCompile @@ -814,14 +768,11 @@ The filenames can deviate according to what the contract's name is. See [here](# ::: -Now, the contract's `.manifest.json` and `.nef` files can be used to deploy the contract. Neow3j's SDK can be used to do -so. Check out the example [here](https://github.com/neow3j/neow3j-examples-java/blob/4d82df91c27bf9d4992c166e1ae98045bd24fbbd/src/main/java/io/neow3j/examples/contractdevelopment/DeployFromFiles.java) -about how to deploy a contract with its manifest and nef files. +Now, the contract's `.manifest.json` and `.nef` files can be used to deploy the contract. Neow3j's SDK can be used to do so. Check out the example [here](https://github.com/neow3j/neow3j-examples-java/blob/4d82df91c27bf9d4992c166e1ae98045bd24fbbd/src/main/java/io/neow3j/examples/contractdevelopment/DeployFromFiles.java) about how to deploy a contract with its manifest and nef files. ## About -Feel free to report any issues that might arise. Open an issue -[here](https://github.com/neow3j/neow3j/issues/new/choose) to help us directly including it in our backlog. +Feel free to report any issues that might arise. Open an issue [here](https://github.com/neow3j/neow3j/issues/new/choose) to help us directly including it in our backlog.