Skip to main content
logo

nft

The nft module is responsible for creating NFT classifications, creating NFTs, transferring NFTs, updating NFTs, and supporting various queries. It is fully compatible with the ERC721 specification.

For more information, visit https://docs.cosmos.network/main/modules/nft/

Message Types

Msg defines the nft Msg service.

tx.proto
Copy

_4
service Msg {
_4
// Send defines a method to send a nft from one account to another account.
_4
rpc Send(MsgSend) returns (MsgSendResponse);
_4
}

MsgSend

MsgSend represents a message to send a nft from one account to another account.

tx.proto
Copy

_15
message MsgSend {
_15
option (cosmos.msg.v1.signer) = "sender";
_15
_15
// class_id defines the unique identifier of the nft classification, similar to the contract address of ERC721
_15
string class_id = 1;
_15
_15
// id defines the unique identification of nft
_15
string id = 2;
_15
_15
// sender is the address of the owner of nft
_15
string sender = 3;
_15
_15
// receiver is the receiver address of nft
_15
string receiver = 4;
_15
}

MsgSendResponse

MsgSendResponse defines the Msg/Send response type.

tx.proto
Copy

_1
message MsgSendResponse {}

Queries

Query defines the gRPC querier service.

query.proto
Copy

_37
service Query {
_37
// Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721
_37
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{owner}/{class_id}";
_37
}
_37
_37
// Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721
_37
rpc Owner(QueryOwnerRequest) returns (QueryOwnerResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/owner/{class_id}/{id}";
_37
}
_37
_37
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.
_37
rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/supply/{class_id}";
_37
}
_37
_37
// NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in
_37
// ERC721Enumerable
_37
rpc NFTs(QueryNFTsRequest) returns (QueryNFTsResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts";
_37
}
_37
_37
// NFT queries an NFT based on its class and id.
_37
rpc NFT(QueryNFTRequest) returns (QueryNFTResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/nfts/{class_id}/{id}";
_37
}
_37
_37
// Class queries an NFT class based on its id
_37
rpc Class(QueryClassRequest) returns (QueryClassResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/classes/{class_id}";
_37
}
_37
_37
// Classes queries all NFT classes
_37
rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) {
_37
option (google.api.http).get = "/cosmos/nft/v1beta1/classes";
_37
}
_37
}

QueryBalanceRequest

QueryBalanceRequest is the request type for the Query/Balance RPC method

query.proto
Copy

_4
message QueryBalanceRequest {
_4
string class_id = 1;
_4
string owner = 2;
_4
}

QueryBalanceResponse

QueryBalanceResponse is the response type for the Query/Balance RPC method

query.proto
Copy

_3
message QueryBalanceResponse {
_3
uint64 amount = 1;
_3
}

QueryOwnerRequest

QueryOwnerRequest is the request type for the Query/Owner RPC method

query.proto
Copy

_4
message QueryOwnerRequest {
_4
string class_id = 1;
_4
string id = 2;
_4
}

QueryOwnerResponse

QueryOwnerResponse is the response type for the Query/Owner RPC method

query.proto
Copy

_3
message QueryOwnerResponse {
_3
string owner = 1;
_3
}

QuerySupplyRequest

QuerySupplyRequest is the request type for the Query/Supply RPC method

query.proto
Copy

_3
message QuerySupplyRequest {
_3
string class_id = 1;
_3
}

QuerySupplyResponse

QuerySupplyResponse is the response type for the Query/Supply RPC method

query.proto
Copy

_3
message QuerySupplyResponse {
_3
uint64 amount = 1;
_3
}

QueryNFTstRequest

QueryNFTstRequest is the request type for the Query/NFTs RPC method

query.proto
Copy

_5
message QueryNFTsRequest {
_5
string class_id = 1;
_5
string owner = 2;
_5
cosmos.base.query.v1beta1.PageRequest pagination = 3;
_5
}

QueryNFTsResponse

QueryNFTsResponse is the response type for the Query/NFTs RPC methods

query.proto
Copy

_4
message QueryNFTsResponse {
_4
repeated cosmos.nft.v1beta1.NFT nfts = 1;
_4
cosmos.base.query.v1beta1.PageResponse pagination = 2;
_4
}

QueryNFTRequest

QueryNFTRequest is the request type for the Query/NFT RPC method.

query.proto
Copy

_4
message QueryNFTRequest {
_4
string class_id = 1;
_4
string id = 2;
_4
}

QueryNFTResponse

QueryNFTResponse is the response type for the Query/NFT RPC method.

query.proto
Copy

_3
message QueryNFTResponse {
_3
cosmos.nft.v1beta1.NFT nft = 1;
_3
}

QueryClassRequest

QueryClassRequest is the request type for the Query/Class RPC method.

query.proto
Copy

_3
message QueryClassRequest {
_3
string class_id = 1;
_3
}

QueryClassResponse

QueryClassResponse is the response type for the Query/Class RPC method.

query.proto
Copy

_3
message QueryClassResponse {
_3
cosmos.nft.v1beta1.Class class = 1;
_3
}

QueryClassesRequest

QueryClassesRequest is the request type for the Query/Classes RPC method.

query.proto
Copy

_4
message QueryClassesRequest {
_4
// pagination defines an optional pagination for the request.
_4
cosmos.base.query.v1beta1.PageRequest pagination = 1;
_4
}

QueryClassesResponse

QueryClassesResponse is the response type for the Query/Classes RPC method.

query.proto
Copy

_4
message QueryClassesResponse {
_4
repeated cosmos.nft.v1beta1.Class classes = 1;
_4
cosmos.base.query.v1beta1.PageResponse pagination = 2;
_4
}