-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#86dtu93ty - Include how to write nft contracts (NEP-11) to the docum… #1270
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just saw that you pasted the direct link to development branch, can you change it to relative path, so when it's merged to staging and master it links to the respective versions? |
||
|
||
## Compiling your Smart Contract | ||
|
||
### Using CLI | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method names are the same for each case, it should need to explain before this that the signatures are different, not only what each method returns