From 95f470e01e190a31a7bc2a7d502ec906638beb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lippi?= Date: Wed, 19 Jun 2024 19:11:00 -0300 Subject: [PATCH 1/2] #86dtu93ty - Include how to write nft contracts (NEP-11) to the documentation --- docs/source/getting-started.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/source/getting-started.md b/docs/source/getting-started.md index 68f80289..8a6d90d9 100644 --- a/docs/source/getting-started.md +++ b/docs/source/getting-started.md @@ -128,6 +128,32 @@ And must also implement and trigger a `Transfer` event whenever tokens are trans Here's a [simple example](https://github.com/CityOfZion/neo3-boa/blob/development/boa3_test/examples/simple_nep17.py) of a Token contract following the NEP-17 standard. >Note: The NEP-17 standard also has requirements on how each method must be implemented. Be sure to check the [full documentation](https://docs.neo.org/docs/en-us/develop/write/nep17.html) on the NEP-17 standard to ensure the implementation is correct. +### How to make a Non-Fungible (NFT) Token smart contract +Just like the fungible token, for a contract to be a non-fungible token (NFT) in the Neo blockchain, it needs to adhere to the [NEP-11](https://docs.neo.org/docs/en-us/develop/write/nep11.html) standard by implementing a few methods and events: +- `symbol` - Returns the symbol of the token. +- `decimals` - Returns the number of decimals used by the token. +- `totalSupply` - Returns the total supply of the token. +- `tokensOf` = Returns the IDs of all NFTs owned by the specified account. + +In addition, an NFT contract may be either *non-divisible* or *divisible*. + +For **non-divisible** NFT contracts, the following method is also required: +- `balanceOf` - Returns the total amount of NFTs of the specified account. +- `transfer` - Transfers tokens to a specified account. +- `ownerOf` - Returns the address of the owner of a specified NFT ID. + +For **divisible** NFT contracts, the following methods are also required: +- `balanceOf` - Returns the amount of NFTs of the specified NFT ID for the specified account. +- `transfer` - Transfers tokens to from a specified account to another. +- `ownerOf` - Returns the addresses of all co-owners of a specified NFT ID. + +In both cases, the contract must also implement and trigger a `Transfer` event whenever tokens are transferred. + +>Note: Although many methods and events have the same name as the NEP-17 standard, their implementation and parameters may differ. + +Here's a [full example](https://github.com/CityOfZion/neo3-boa/blob/development/boa3_test/examples/nep11_non_divisible.py) of a non-divisible token contract following the NEP-11 standard. +>Note: The example above is rather complete and contains more than just the basic implementation of a NEP-11 contract. Once again, be sure to check the [full documentation](https://docs.neo.org/docs/en-us/develop/write/nep11.html) on the NEP-11 standard to ensure the implementation is correct. + ## Compiling your Smart Contract ### Using CLI From 0a6ece6c9e6e7a7090a87b8328d607a1aa0c31aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lippi?= Date: Wed, 19 Jun 2024 19:33:26 -0300 Subject: [PATCH 2/2] #86dtu93ty - Include how to write nft contracts (NEP-11) to the documentation --- docs/source/getting-started.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/source/getting-started.md b/docs/source/getting-started.md index 8a6d90d9..d885192c 100644 --- a/docs/source/getting-started.md +++ b/docs/source/getting-started.md @@ -125,7 +125,7 @@ For a smart contract to be a fungible token on the Neo blockchain, it needs to a And must also implement and trigger a `Transfer` event whenever tokens are transferred, minted or burned. -Here's a [simple example](https://github.com/CityOfZion/neo3-boa/blob/development/boa3_test/examples/simple_nep17.py) of a Token contract following the NEP-17 standard. +Here's a [simple example](../../boa3_test/examples/simple_nep17.py) of a Token contract following the NEP-17 standard. >Note: The NEP-17 standard also has requirements on how each method must be implemented. Be sure to check the [full documentation](https://docs.neo.org/docs/en-us/develop/write/nep17.html) on the NEP-17 standard to ensure the implementation is correct. ### How to make a Non-Fungible (NFT) Token smart contract @@ -135,23 +135,22 @@ Just like the fungible token, for a contract to be a non-fungible token (NFT) in - `totalSupply` - Returns the total supply of the token. - `tokensOf` = Returns the IDs of all NFTs owned by the specified account. -In addition, an NFT contract may be either *non-divisible* or *divisible*. +In addition, an NFT contract may be either *non-divisible* or *divisible*. The remaining methods have the same name, but different **signatures** for each, and different returns: +- For **non-divisible** NFT contracts: + - `balanceOf` - Returns the total amount of NFTs of the specified account. + - `transfer` - Transfers tokens to a specified account. + - `ownerOf` - Returns the address of the owner of a specified NFT ID. -For **non-divisible** NFT contracts, the following method is also required: -- `balanceOf` - Returns the total amount of NFTs of the specified account. -- `transfer` - Transfers tokens to a specified account. -- `ownerOf` - Returns the address of the owner of a specified NFT ID. - -For **divisible** NFT contracts, the following methods are also required: -- `balanceOf` - Returns the amount of NFTs of the specified NFT ID for the specified account. -- `transfer` - Transfers tokens to from a specified account to another. -- `ownerOf` - Returns the addresses of all co-owners of a specified NFT ID. +- For **divisible** NFT contracts: + - `balanceOf` - Returns the amount of NFTs of the specified NFT ID for the specified account. + - `transfer` - Transfers tokens to from a specified account to another. + - `ownerOf` - Returns the addresses of all co-owners of a specified NFT ID. In both cases, the contract must also implement and trigger a `Transfer` event whenever tokens are transferred. >Note: Although many methods and events have the same name as the NEP-17 standard, their implementation and parameters may differ. -Here's a [full example](https://github.com/CityOfZion/neo3-boa/blob/development/boa3_test/examples/nep11_non_divisible.py) of a non-divisible token contract following the NEP-11 standard. +Here's a [full example](../../boa3_test/examples/nep11_non_divisible.py) of a non-divisible token contract following the NEP-11 standard. >Note: The example above is rather complete and contains more than just the basic implementation of a NEP-11 contract. Once again, be sure to check the [full documentation](https://docs.neo.org/docs/en-us/develop/write/nep11.html) on the NEP-11 standard to ensure the implementation is correct. ## Compiling your Smart Contract @@ -177,8 +176,8 @@ Boa3.compile_and_save('path/to/your/file.py') Check out [Neo3-boa tutorials](https://developers.neo.org/tutorials/tags/neo-3-boa) on [Neo Developer](https://developers.neo.org/). For an extensive collection of examples: -- [Smart contract examples](https://github.com/CityOfZion/neo3-boa/blob/development/boa3_test/examples) -- [Features tests](https://github.com/CityOfZion/neo3-boa/blob/development/boa3_test/test_sc) +- [Smart contract examples](../../boa3_test/examples) +- [Features tests](../../boa3_test/test_sc) ## What's next