Response Interface
export interface CW721Response<T> {
cw721: T;
}
queryAllNFTInfo
Queries a CW721 contract for all info for a given token ID.
export async function queryAllNFTInfo(
contractAddress: string,
tokenId: string,
includeExpired: boolean = false
): Promise<QueryCW721AllNFTInfoResponse["cw721"]["allNftInfo"]> {
const resp = await query<QueryCW721AllNFTInfo, QueryCW721AllNFTInfoResponse>(
QUERY_CW721_ALL_NFT_INFO,
{ contractAddress, tokenId, includeExpired }
);
return resp.cw721.allNftInfo;
}
QueryCW721AllNFTInfo
export interface QueryCW721AllNFTInfo extends ContractAddressQuery {
includeExpired: boolean;
tokenId: string;
}
QueryCW721AllNFTInfoResponse
export type QueryCW721AllNFTInfoResponse = CW721Response<{
allNftInfo: {
access: NFTOwnerInfo;
info: NFTInfo;
};
}>;
NFTOwnerInfo
export interface NFTOwnerInfo {
approvals: NFTApproval[];
owner: string;
}
NFTApproval
export interface NFTApproval {
expires: Expiry;
spender: string;
}
NFTInfo
export interface NFTInfo {
extension: NFTExtension;
tokenUri: string;
}
NFTExtension
export interface NFTExtension {
name: string;
publisher: string;
description?: string;
attributes: NFTAttribute[];
image: string;
image_data?: string;
external_url?: string;
animation_url?: string;
youtube_url?: string;
}
NFTAttribute
export interface NFTAttribute {
trait_type: string;
value: string;
display_type?: string;
}
queryAllOperators
Queries any operators for a given address.
export async function queryAllOperators(
contractAddress: string,
owner: string,
includeExpired: boolean = false,
options?: AndrSearchOptions
): Promise<QueryCW721AllOperatorsResponse["cw721"]["allOperators"]> {
const resp = await query<
QueryCW721AllOperators,
QueryCW721AllOperatorsResponse
>(QUERY_CW721_ALL_OPERATORS, {
contractAddress,
includeExpired,
owner,
options,
});
return resp.cw721.allOperators;
}
QueryCW721AllOperators
export interface QueryCW721AllOperators
extends ContractAddressQuery,
PaginatedQuery {
includeExpired: boolean;
owner: string;
}
QueryCW721AllOperatorsResponse
export type QueryCW721AllOperatorsResponse = CW721Response<{
allOperators: NFTApproval[];
}>;
NFTApproval
export interface NFTApproval {
expires: Expiry;
spender: string;
}
queryAllTokens
Queries a CW721 contract for all tokens.
export async function queryAllTokens(
contractAddress: string,
options?: AndrSearchOptions
): Promise<string[]> {
const resp = await query<QueryCW721AllTokens, QueryCW721AllTokensResponse>(
QUERY_CW721_ALL_TOKENS,
{ contractAddress, options }
);
return resp.cw721.allTokens;
}
QueryCW721AllTokens
export interface QueryCW721AllTokens
extends ContractAddressQuery,
PaginatedQuery {}
QueryCW721AllTokensResponse
export type QueryCW721AllTokensResponse = CW721Response<{
allTokens: string[];
}>;
queryApproval
Queries a CW721 contract for whether a given address is an assigned operator for a given token.
export async function queryApproval(
contractAddress: string,
spender: string,
tokenId: string,
includeExpired: boolean = false
): Promise<NFTApproval> {
const resp = await query<QueryCW721Approval, QueryCW721ApprovalResponse>(
QUERY_CW721_APPROVAL,
{ contractAddress, spender, tokenId, includeExpired }
);
return resp.cw721.approval;
}
QueryCW721Approval
export interface QueryCW721Approval extends ContractAddressQuery {
includeExpired: boolean;
spender: string;
tokenId: string;
}
QueryCW721ApprovalResponse
export type QueryCW721ApprovalResponse = CW721Response<{
approval: NFTApproval;
}>;
queryApprovals
Queries all the approvals a token has.
export async function queryApprovals(
contractAddress: string,
tokenId: string,
includeExpired: boolean = false
): Promise<QueryCW721ApprovalsResponse["cw721"]["approvals"]> {
const resp = await query<QueryCW721Approvals, QueryCW721ApprovalsResponse>(
QUERY_CW721_APPROVALS,
{ contractAddress, tokenId, includeExpired }
);
return resp.cw721.approvals;
}
QueryCW721Approvals
export interface QueryCW721Approvals extends ContractAddressQuery {
includeExpired: boolean;
tokenId: string;
}
QueryCW721ApprovalsResponse
export type QueryCW721ApprovalsResponse = CW721Response<{
approvals: NFTApproval[];
}>;
queyContractInfo
Queries a CW721 contract for its contract info.
export async function queryContractInfo(
contractAddress: string
): Promise<QueryCW721ContractInfoResponse["cw721"]["contractInfo"]> {
const resp = await query<
QueryCW721ContractInfo,
QueryCW721ContractInfoResponse
>(QUERY_CW721_CONTRACT_INFO, { contractAddress });
return resp.cw721.contractInfo;
}
QueryCW721ContractInfo
export interface QueryCW721ContractInfo extends ContractAddressQuery {}
QueryCW721ContractInfoResponse
export type QueryCW721ContractInfoResponse = CW721Response<{
contractInfo: NFTContractInfo;
minter: string;
numTokens: number;
}>;
NFTContractInfo
export interface NFTContractInfo {
name: string;
symbol: string;
}
queryIsArchived
Queries a CW721 contract whether a given token ID is archived.
export async function queryIsArchived(
contractAddress: string,
tokenId: string
): Promise<boolean> {
const resp = await query<QueryCW721IsArchived, QueryCW721IsArchivedResponse>(
QUERY_CW721_IS_ARCHIVED,
{ contractAddress, tokenId }
);
return resp.cw721.isArchived;
}
QueryCW721IsArchived
export interface QueryCW721IsArchived extends ContractAddressQuery {
tokenId: string;
}
QueryCW721IsArchivedResponse
export type QueryCW721IsArchivedResponse = CW721Response<{
isArchived: boolean;
}>;
queryNFTInfo
Queries a CW721 contract for a given token IDs NFT info.
export async function queryNFTInfo(
contractAddress: string,
tokenId: string
): Promise<QueryCW721NftInfoResponse["cw721"]["nftInfo"]> {
const resp = await query<QueryCW721NFTInfo, QueryCW721NftInfoResponse>(
QUERY_CW721_NFT_INFO,
{ contractAddress, tokenId }
);
return resp.cw721.nftInfo;
}
QueryCW721NFTInfo
export interface QueryCW721NFTInfo extends ContractAddressQuery {
tokenId: string;
}
QueryCW721NFTInfoResponse
export type QueryCW721NftInfoResponse = CW721Response<{
nftInfo: NFTInfo;
}>;
queryOwnerOf
Queries a CW721 contract for the owner of a given token ID.
export async function queryOwnerOf(
contractAddress: string,
tokenId: string
): Promise<string> {
const resp = await query<QueryCW721OwnerOf, QueryCW721OwnerOfResponse>(
QUERY_CW721_OWNER_OF,
{ contractAddress, tokenId }
);
return resp.cw721.ownerOf.owner;
}
QueryCW721OwnerOf
export interface QueryCW721OwnerOf extends ContractAddressQuery {
tokenId: string;
}
QueryCW721OwnerOfResponse
export type QueryCW721OwnerOfResponse = CW721Response<{
ownerOf: { owner: string };
}>;
queryTokens
Queries a CW721 contract for all tokens owned by a given address.
export async function queryTokens(
contractAddress: string,
owner: string,
options?: AndrSearchOptions
): Promise<QueryCW721TokensResponse["cw721"]["tokens"]> {
const resp = await query<QueryCW721Tokens, QueryCW721TokensResponse>(
QUERY_CW721_TOKENS,
{ contractAddress, owner, options }
);
return resp.cw721.tokens;
}
QueryCW721Tokens
export interface QueryCW721Tokens extends ContractAddressQuery, PaginatedQuery {
owner: string;
}
QueryCW721TokensResponse
export type QueryCW721TokensResponse = CW721Response<{
tokens: string[];
}>;
queryTransferAgreement
Queries a CW721 contract for the transfer agreement for a given token ID.
export async function queryTransferAgreement(
contractAddress: string,
tokenId: string
): Promise<TransferAgreement> {
const resp = await query<
QueryCW721TransferAgreement,
QueryCW721TransferAgreementResponse
>(QUERY_CW721_TRANSFER_AGREEMENT, { contractAddress, tokenId });
return resp.transferAgreement;
}
QueryCW721TransferAgreement
export interface QueryCW721TransferAgreement extends ContractAddressQuery {
tokenId: string;
}
QueryCW721TransferAgreementResponse
export type QueryCW721TransferAgreementResponse = CW721Response<{
transferAgreement: TransferAgreement;
}>;
Returns a TransferAgreement if found.
TransferAgreement
export interface TransferAgreement {
tokenId: string;
agreement: Agreement;
}
Agreement
export interface Agreement {
amount: { raw: Coin };
purchaser: string;
}