Bumps [cosmossdk.io/api](https://github.com/cosmos/cosmos-sdk) from 0.3.0 to 0.3.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/cosmos/cosmos-sdk/blob/v0.3.1/CHANGELOG.md">cosmossdk.io/api's changelog</a>.</em></p> <blockquote> <h2>0.3.1 (March 23, 2017)</h2> <p>IMPROVEMENTS:</p> <ul> <li>CLI returns exit code 1 and logs error before exiting</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/cosmos/cosmos-sdk/compare/v0.3.0...v0.3.1">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> |
||
|---|---|---|
| .. | ||
| client/cli | ||
| internal/conv | ||
| keeper | ||
| module | ||
| simulation | ||
| testutil | ||
| CHANGELOG.md | ||
| codec.go | ||
| errors.go | ||
| event.pb.go | ||
| expected_keepers.go | ||
| genesis.go | ||
| genesis.pb.go | ||
| go.mod | ||
| go.sum | ||
| keys.go | ||
| msgs.go | ||
| nft.pb.go | ||
| query.pb.go | ||
| query.pb.gw.go | ||
| README.md | ||
| sonar-project.properties | ||
| tx.pb.go | ||
| sidebar_position |
|---|
| 1 |
x/nft
Contents
Abstract
x/nft is an implementation of a Cosmos SDK module, per ADR 43, that allows you to create nft classification, create nft, transfer nft, update nft, and support various queries by integrating the module. It is fully compatible with the ERC721 specification.
Concepts
Class
x/nft module defines a struct Class to describe the common characteristics of a class of nft, under this class, you can create a variety of nft, which is equivalent to an erc721 contract for Ethereum. The design is defined in the ADR 043.
NFT
The full name of NFT is Non-Fungible Tokens. Because of the irreplaceable nature of NFT, it means that it can be used to represent unique things. The nft implemented by this module is fully compatible with Ethereum ERC721 standard.
State
Class
Class is mainly composed of id, name, symbol, description, uri, uri_hash,data where id is the unique identifier of the class, similar to the Ethereum ERC721 contract address, the others are optional.
- Class:
0x01 | classID | -> ProtocolBuffer(Class)
NFT
NFT is mainly composed of class_id, id, uri, uri_hash and data. Among them, class_id and id are two-tuples that identify the uniqueness of nft, uri and uri_hash is optional, which identifies the off-chain storage location of the nft, and data is an Any type. Use Any chain of x/nft modules can be customized by extending this field
- NFT:
0x02 | classID | 0x00 | nftID |-> ProtocolBuffer(NFT)
NFTOfClassByOwner
NFTOfClassByOwner is mainly to realize the function of querying all nfts using classID and owner, without other redundant functions.
- NFTOfClassByOwner:
0x03 | owner | 0x00 | classID | 0x00 | nftID |-> 0x01
Owner
Since there is no extra field in NFT to indicate the owner of nft, an additional key-value pair is used to save the ownership of nft. With the transfer of nft, the key-value pair is updated synchronously.
- OwnerKey:
0x04 | classID | 0x00 | nftID |-> owner
TotalSupply
TotalSupply is responsible for tracking the number of all nfts under a certain class. Mint operation is performed under the changed class, supply increases by one, burn operation, and supply decreases by one.
- OwnerKey:
0x05 | classID |-> totalSupply
Messages
In this section we describe the processing of messages for the NFT module.
:::warning
The validation of ClassID and NftID is left to the app developer.
The SDK does not provide any validation for these fields.
:::
MsgSend
You can use the MsgSend message to transfer the ownership of nft. This is a function provided by the x/nft module. Of course, you can use the Transfer method to implement your own transfer logic, but you need to pay extra attention to the transfer permissions.
The message handling should fail if:
- provided
ClassIDdoes not exist. - provided
Iddoes not exist. - provided
Senderdoes not the owner of nft.
Events
The nft module emits proto events defined in the Protobuf reference.