Introduction
The CW721 ADO is a smart contract to allow users to launch their own custom NFT projects. In addition to the standard CW721 messages, we have added some custom logic to further extend the utility and function of the contract.
The CW721 ADO is one of the base ADOs meaning it can interact with a large number of other ADOs such as the marketplace, crowdfund, auction, CW721 timelock and many more.
The contract has implemented a custom TransferAgreement
message to allow the buying/selling of tokens between two parties throught the CW721 ADO itself.
Ado_type : cw721
Version: 2.0.3-beta.1
InstantiateMsg
Rust JSON
Copy pub struct InstantiateMsg {
pub name : String ,
pub symbol : String ,
pub minter : AndrAddr ,
pub kernel_address : String ,
pub owner : Option < String >,
}
Copy {
"name" : "Example Token" ,
"symbol" : "ET" ,
"minter" : "andr1..." ,
"kernel_address" : "andr1..."
}
ExecuteMsg
Mint
Mints a new NFT.
Only available to the defined minter
in the InstantiateMsg.
Rust JSON
Copy pub enum ExecuteMsg {
Mint {
pub token_id : String ,
pub owner : String ,
pub token_uri : Option < String >,
pub extension : TokenExtension ,
}
}
Copy {
"mint": {
"token_id" : "1" ,
"owner" : "andr1..." ,
"token_uri" : "https://gateway.pinata.cloud/ipfs..." ,
"extension" : {
"publisher" : "Andromeda"
}
}
}
TokenExtension
Extension that can be added to an NFT when minting.
Copy pub struct TokenExtension {
pub publisher : String ,
}
BatchMint
Mint several NFTs at once.
Rust JSON
Copy pub enum ExecuteMsg {
BatchMint {
tokens : Vec < MintMsg >,
}
}
Copy {
"batch_mint" : {
"tokens" : [
{
"token_id" : "1" ,
"owner" : "andr1..." ,
"token_uri" : "https://gateway.pinata.cloud/ipfs..." ,
"extension" : {
"publisher" : "Andromeda"
}
} ,
{
"token_id" : "2" ,
"owner" : "andr1..." ,
"token_uri" : "https://gateway.pinata.cloud/ipfs..." ,
"extension" : {
"publisher" : "Andromeda"
}
} ,
{
"token_id" : "3" ,
"owner" : "andr1..." ,
"token_uri" : "https://gateway.pinata.cloud/ipfs..." ,
"extension" : {
"publisher" : "Andromeda"
}
}
]
}
}
TransferAgreement
Assigns a TransferAgreement
for a token. If the agreement
field is not set, the message will remove any previously set agreements on the token (Instead of making a new RemoveAgreement message).
Only available to the token owner.
Rust JSON
Copy pub enum ExecuteMsg {
TransferAgreement {
token_id : String ,
agreement : Option < TransferAgreement >,
}
}
Copy {
"transfer_agreement" : {
"token_id" : "1" ,
"agreement" : {
"amount" : {
"raw" : {
"denom" : "uandr" ,
"amount" : "1000000"
}
} ,
"purchaser" : "andr1..."
}
}
}
TransferAgreement
The purchaser
may use the TransferNft
message for this token as long as funds are provided equaling the amount
defined in the agreement.
If the purchaser
is set to "*"
then anyone can complete the TransferAgreement
(Anyone can buy the NFT).
Copy pub struct TransferAgreement {
pub amount : Coin ,
pub purchaser : String ,
}
TransferNft
A CW721 compliant transfer method. Transfers ownership of a minted token.
Archived tokens cannot be transferred.
Only available to the contract owner, an approved operator, or a purchaser in a TransferAgreement
for the given token.
Rust JSON
Copy pub enum ExecuteMsg {
TransferNft {
recipient : AndrAddr ,
token_id : String ,
}
}
Copy {
"transfer_nft" : {
"recipient" : "andr1..." ,
"token_id" : "anewtoken"
}
}
SendNft
A CW721 compliant send method. Sends ownership of a minted token to an external contract.
Only available to the token owner/operator/approved address.
Rust JSON
Copy pub enum ExecuteMsg {
SendNft {
contract : AndrAddr ,
token_id : String ,
msg : Binary ,
}
}
Copy {
"send_nft" : {
"contract" : "andr1..." ,
"token_id" : "anewtoken" ,
"msg":"eyJzdGFydF9hdWN0aW9uIjogeyJzdGFydF90aW1lIjogMTY2MzMzNDk3MDIxMSwiZHVyYXRpb24iOiA5MDAwMDAsImNvaW5fZGVub20iOiAidWFuZHIiLCJtaW5fYmlkIjoiMzAwIiwid2hpdGVsaXN0IjogWyJhbmRyMS4uLiIsICJhbmRyMS4uLiIsIC4uLl19fQ=="
}
}
Burn
Destroys any token data related to an token Id. The Id of the token is still reserved.
Cannot be undone.
Only available to the token owner.
Rust JSON
Copy pub enum ExecuteMsg {
Burn {
token_id : String ,
},
}
Copy {
"burn" : {
"token_id" : "1"
}
}
Archive
Archives an token, making it immutable in any respect. Once an token is archived it cannot be edited, transferred or burnt.
Cannot be undone.
Only available to the token owner.
Rust JSON
Copy pub enum ExecuteMsg {
Archive {
token_id : String ,
}
}
Copy {
"archive" : {
"token_id" : "1"
}
}
Approve
A CW721 compliant approve method. Approves a given address as an operator for the token, allowing them to transfer, burn or archive the token.
Only available to the token owner/operator.
Rust JSON
Copy pub enum ExecuteMsg {
Approve {
spender : String ,
token_id : String ,
expires : Option < Expiration >,
}
}
Copy {
"approve" : {
"spender" : "andr1..." ,
"token_id" : "1"
}
}
Revoke
A CW721 compliant revoke method. Revokes operator privileges for a given address.
Only available to the token owner/operator.
Rust JSON
Copy pub enum ExecuteMsg {
Revoke {
spender : String ,
token_id : String ,
}
}
Copy {
"revoke" : {
"spender" : "andr1..." ,
"token_id" : "1"
}
}
ApproveAll
A CW721 compliant approve all method. Approves a given address as an operator for all tokens owned by the sender.
Will overwrite any approval currently assigned to the operator's address.
Rust JSON
Copy pub enum ExecuteMsg {
ApproveAll {
operator : String ,
expires : Option < Expiration >,
}
}
Copy {
"approve_all" : {
"operator" : "andr1..."
}
}
RevokeAll
A CW721 compliant revoke all method. Revokes an operator's privileges for any tokens owned by the sender.
Rust JSON
Copy pub enum ExecuteMsg {
RevokeAll {
operator : String ,
}
}
Copy {
"revoke_all" : {
"operator" : "andr1..."
}
}
Base Executes
The rest of the execute messages can be found in the ADO Base section.
QueryMsg
Minter
Queries the current minter of the contract.
Rust JSON
Copy pub enum QueryMsg {
#[returns( MinterResponse )]
Minter {},
}
MinterResponse
Rust JSON
Copy pub struct MinterResponse {
minter : Option < String >,
}
Copy {
"minter" : "andr1..."
}
OwnerOf
A CW721 compliant "owner of" query. Queries the current owner of a given token Id.
Rust JSON
Copy pub enum QueryMsg {
#[returns( OwnerOfResponse )]
OwnerOf {
token_id : String ,
include_expired : bool ,
}
}
Copy {
"owner_of" : {
"token_id" : "1" ,
"include_expired" : false
}
}
OwnerOfResponse
Rust JSON
Copy pub struct OwnerOfResponse {
pub owner : String ,
pub approvals : Vec < Approval >,
}
Copy {
"owner" : "andr1..." ,
"approvals" : [
{
"spender" : "andr1..." ,
"expires" : "never"
}
]
}
Approval
Copy pub struct Approval {
pub spender : String ,
pub expires : Expiration ,
}
Operator
Returns the approval of a given operator for all tokens of an owner. Errors if no approvals are set.
Rust JSON
Copy pub enum QueryMsg {
#[returns(cw721 :: OperatorResponse )]
Operator {
owner : String ,
operator : String ,
include_expired : Option < bool >,
}
}
OperatorResponse
Rust JSON
Copy #[cw_serde]
pub struct OperatorResponse {
pub approval : Approval ,
}
Copy {
"approval" : {
"spender" : "andr1..." ,
"expires" : {
"at_time" : "16705100749238434832"
}
}
}
Returns an Approval struct.
AllOperators
List all operators that can access all of the owner's tokens.
Rust JSON
Copy pub enum QueryMsg {
#[returns( OperatorsResponse )]
AllOperators {
owner : String ,
include_expired : Option < bool >,
start_after : Option < String >,
limit : Option < u32 >,
},
Copy {
"all_operators" : {
"owner" : "andr1..." ,
"include_expired" : true ,
"start_after" : "andr1..." ,
"limit" : 10
}
}
OperatorsResponse
Rust JSON
Copy pub struct OperatorsResponse {
pub operators : Vec < Approval >,
}
Copy {
"operators" : [
{
"spender" : "andr1..." ,
"expires" : {
"at_time" : "16705100749238434832"
}
} ,
...
]
}
NumTokens
A CW721 compliant "num tokens" query. Queries the amount of tokens minted by the contract.
Rust JSON
Copy pub enum QueryMsg {
#[returns( NumTokensResponse )]
NumTokens {}
}
NumTokensResponse
Rust JSON
Copy pub struct NumTokensResponse {
pub count : u64 ,
}
NftInfo
A CW721 compliant "nft info" query. Queries the stored info of a token.
Rust JSON
Copy pub enum QueryMsg {
#[returns( NftInfoResponse < TokenExtension >)]
NftInfo {
token_id : String ,
}
}
Copy {
"nft_info" : {
"token_id" : "1"
}
}
NftInfoResponse
Rust JSON
Copy pub struct NftInfoResponse < T > {
pub token_uri : Option < String >,
pub extension : T ,
}
Copy {
"extension" :{
"name" : "mytoken" ,
"publisher" : "publisher" ,
"description" : "This token ...." ,
"archived" : false
}
}
AllNftInfo
A CW721 compliant "all nft info" query. Queries all stored info of an token.
Rust JSON
Copy pub enum QueryMsg {
#[returns( AllNftInfoResponse < TokenExtension >)]
AllNftInfo {
token_id : String ,
include_expired : Option < bool >
}
}
Copy {
"all_nft_info" : {
"token_id" : "1" ,
"include_expired" : false
}
}
AllNftInfoResponse
Rust JSON
Copy pub struct AllNftInfoResponse < T > {
pub access : OwnerOfResponse ,
pub info : NftInfoResponse < T >,
}
Copy {
"access" : {
"owner" : "andr1..." ,
"approvals" : [
{
"spender" : "andr1..." ,
"expires" : "never"
}
]
} ,
"info" : {
"name" : "A New Token" ,
"description" : "A newly minted token" ,
"extension" : {
"archived" : false ,
"metadata" : "{ \"some_json_field\": \"some_json_value\" }" ,
"agreement" : {
"purchaser" : "andr1..." ,
"amount" : "100uandr"
}
}
}
}
IsArchived
Checks if the token with the specified token_id
is archived.
Rust JSON
Copy pub enum QueryMsg {
#[returns( bool )]
IsArchived {
token_id : String ,
}
}
Copy {
"is_archived" : {
"token_id" : "3"
}
}
Returns a bool value.
TransferAgreement
Checks if the token has a TransferAgreement .
Rust JSON
Copy pub enum QueryMsg {
#[returns( Option < TransferAgreement >)]
TransferAgreement {
token_id : String ,
}
}
Copy {
"transfer_agreement" : {
"token_id" : "3"
}
}
Returns None if no TransferAgreement is found, and the TransferAgreement struct otherwise.
Tokens
Queries all the tokens of a particular owner.
Rust JSON
Copy pub enum QueryMsg {
#[returns( TokensResponse )]
Tokens {
owner : String ,
start_after : Option < String >,
limit : Option < u32 >,
}
}
Copy {
"tokens" : {
"owner" : "andr1..." ,
"start_after" : "3" ,
"limit" : 25
}
}
TokensResponse
Contains all token_ids in lexicographical ordering. If there are more than limit
, use start_from
in future queries to achieve pagination.
Copy pub struct TokensResponse {
pub tokens : Vec < String >,
}
AllTokens
Queries the tokens minted by the contract.
Rust JSON
Copy pub enum QueryMsg {
#[returns( TokensResponse )]
AllTokens {
start_after : Option < String >,
limit : Option < u32 >,
}
}
Copy {
"all_tokens" : {
"limit" : 5
}
}
TokensResponse
Contains all token_ids in lexicographical ordering. If there are more than limit
, use start_from
in future queries to achieve pagination.
Copy pub struct TokensResponse {
pub tokens : Vec < String >,
}
ContractInfo
Queries the name and symbol of the token collection.
Rust JSON
Copy pub enum QueryMsg {
#[returns( ContractInfoResponse )]
ContractInfo {}
}
Copy {
"contract_info" : {}
}
ContractInfoResponse
Rust JSON
Copy pub struct CotractInfoResponse {
pub name : String ,
pub symbol : String ,
}
Copy {
"name" : "Example Token" ,
"symbol" : "ET"
}
Approval
Queries the spender's approval to check for the expiration.
Rust JSON
Copy pub enum QueryMsg {
Approval {
token_id : String ,
spender : String ,
include_expired : Option < bool >,
}
}
Copy {
"approval" : {
"token_id" : "my_token" ;
"spender" : "andr1..." ;
"include_expired" : true
}
}
ApprovalResponse
Rust JSON
Copy pub struct ApprovalResponse {
pub approval : Approval ,
}
Copy {
"spender" : "andr1..." ;
"expires" :{
"at_height" : 500
}
}
Copy pub struct Approval {
pub spender : String ,
pub expires : Expiration ,
}
Approvals
Returns all the approvals a token has.
Rust JSON
Copy pub enum QueryMsg {
Approvals {
token_id : String ,
include_expired : Option < bool >,
}
}
Copy {
"approval" : {
"token_id" : "my_token" ;
"include_expired" : true
}
}
ApprovalsResponse
Rust JSON
Copy pub struct ApprovalsResponse {
pub approvals : Vec < Approval >,
}
Copy {
"approvals" : [
{
"spender" : "andr1..." ;
"expires" :{
"at_height" : 500
}
} ,
{
"spender" : "andr1..." ;
"expires" :{
"at_height" : 500
}
} ,
...
]
}
Return a vector of Approval .
Base Queries
The rest of the query messages can be found in the ADO Base section.