Andromeda
Search
K

CW721

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.
It supports the use of all our modules that can be attached to the contract upon instantiation and modified to satisfy the project needs. The CW721 Bids Module is specifically created to work with this ADO to facilitate the process of buying/selling the tokens.
In addition to the bids module, the contract has implemented a custom TransferAgreement message to allow the buying/selling of tokens between two parties throught the CW721 ADO itself.
The contract supports modules to extend its functionality.
Ado_type: cw721

InstantiateMsg

Rust
JSON
pub struct InstantiateMsg {
pub name: String,
pub symbol: String,
pub minter: AndrAddress,
pub modules: Option<Vec<Module>>,
}
{
"name": "Example Token",
"symbol": "ET",
"minter":{
"identifier":"andr1..."
},
"modules": [
{
"module_type": "address_list",
"address": {
"identifier":"andr1..."
}
"is_mutable": false
},
{
...
}
]
}
Name
Type
Description
name
String
The name of the NFT collection.
symbol
String
The symbol of the NFT collection.
minter
The address of the token minter. The specified minter is the only address allowed to mint NFTs. Cannot be changed.
modules
Option<Vec<Module>>
An optional vector of Andromeda Modules that can be attached to the contract. "rates", "address-list" and "offers" modules can be added.

ExecuteMsg

Mint

Mints a new NFT.
Only available to the defined minter in the InstantiateMsg.
Rust
JSON
pub struct MintMsg<T> {
pub token_id: String,
pub owner: String,
pub token_uri: Option<String>,
pub extension: T,
}
pub enum ExecuteMsg {
Mint(box<MintMsg<TokenExtension>>)
}
{
"mint": {
"token_id": "1",
"owner": "andr1...",
"extension": {
"name": "Some token",
"publisher": "Andromeda",
"description": "A minted token for testing",
"attributes": [
{
"trait_type": "Trait One",
"value": "ABC",
"display_type": "String"
}
],
"image": "https://google.com"
}
}
}
Name
Type
Description
token_id
String
The id of the token to be minted.
owner
String
The address of the token owner.
token_uri
Option<String>
Universal resource identifier for this token. Should point to a JSON file that conforms to the CW721 Metadata JSON Schema.
extension
T (Generic type)
Any custom extension used by this contract. Here we use TokenExtension.

TokenExtension

Extension that can be added to an NFT when minting.
pub struct TokenExtension {
pub name: String,
pub publisher: String,
pub description: Option<String>,
pub attributes: Vec<MetadataAttribute>,
pub image: String,
pub image_data: Option<String>,
pub external_url: Option<String>,
pub animation_url: Option<String>,
pub youtube_url: Option<String>,
}
Name
Type
Description
name
String
The name of the token.
publisher
String
The original publisher of the token (immutable).
description
Option<String>
An optional description of the token.
attributes
Vec<MetadataAttribute>
The metadata of the token if it exists.
image
String
URL to the token image.
image_data
Option<String>
Raw SVG image data
external_url
Option<String>
A URL to the token's source.
animation_url
Option<String>
A URL to any multi-media attachments.
youtube_url
Option<String>
A URL to a related Youtube video.

MetadataAttribute

pub struct MetadataAttribute {
pub trait_type: String,
pub value: String,
pub display_type: Option<String>,
}
Name
Type
Description
trait_type
String
The key for the attribute.
value
String
The value for the attribute
display_type
Option<String>
The string used to display the attribute, if none is provided the trait_type field can be used.

BatchMint

Mint several NFTs at once.
Rust
JSON
pub enum ExecuteMsg {
BatchMint {
tokens: Vec<MintMsg<TokenExtension>>,
}
}
{
"batch_mint": {
"tokens": [
{
"token_id": "1",
"owner": "andr1...",
"extension": {
"name": "Token 1",
"publisher": "Andromeda",
"attributes": [],
"archived": false,
"image": "https://pic.onlinewebfonts.com/svg/img_522399.png"
}
},
{
"token_id": "2",
"owner": "andr1...",
"extension": {
"name": "Token 2",
"publisher": "Andromeda",
"attributes": [],
"archived": false,
"image": "https://pic.onlinewebfonts.com/svg/img_522399.png"
}
},
{
"token_id": "3",
"owner": "andr1...",
"extension": {
"name": "Token 3",
"publisher": "Andromeda",
"attributes": [],
"archived": false,
"image": "https://pic.onlinewebfonts.com/svg/img_522399.png"
}
}
]
}
}
Name
Type
Description
tokens
Vector of MintMsg. Similar to minting one token, but allows minting of many tokens in one go.

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
pub enum ExecuteMsg {
TransferAgreement {
token_id: String,
agreement: Option<TransferAgreement>,
}
}
{
"transfer_agreement":{
"token_id":"1",
"agreement":{
"amount":{
"raw":{
"denom":"uandr",
"amount":"1000000"
}
},
"purchaser":"andr1..."
}
}
}
Name
Type
Description
token_id
String
The token id of the NFT we want to add an agreement for.
agreement
Option<TransferAgreement>
The agreement for the token containing the selling price and the address allowed to purchase the token. If not specified then any previously set agreement is removed from the token.

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 token)
pub struct TransferAgreement {
pub amount: Value<Coin>,
pub purchaser: String,
}
Name
Type
Description
amount
Value<Coin>
The amount required for the purchaser to transfer ownership of the token.
purchaser
String
The address of the purchaser.

Value<T>

pub enum Value<T>
where
// This restriction is to ensure that `T` is a type that can be stored as a `Primitive`. It
// could work without, but we could easily get cases where `T` cannot be a `Primitive` and this
// gives us compile-time insurance.
T: Into<Primitive>,
{
/// The raw value.
Raw(T),
/// The pointer to the primitive. This SHOULD be of the same underlying type as `T`. For
/// example, if `T` is `String`, then `PrimitivePointer` should point to a Primitive::String(..).
/// This cannot be enforced at compile time though, so it is up to the discretion of the user.
Pointer(PrimitivePointer),
}

PrimitivePointer

pub struct PrimitivePointer {
pub address: AndrAddress,
pub key: Option<String>,
}
Name
Type
Description
address
The address of the primitive contract.
key
Option<String>
The optional key for the stored data.

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
pub enum ExecuteMsg {
TransferNft {
recipient: String,
token_id: String,
}
}
{
"transfer_nft": {
"recipient": "andr1...",
"token_id": "anewtoken"
}
}
Name
Type
Description
recipient
String
The address of the recipient.
token_id
String
The id of the token to be transferred.

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
pub enum ExecuteMsg {
SendNft {
contract: String,
token_id: String,
msg: Binary,
}
}
{
"send_nft": {
"contract": "andr1...",
"token_id": "anewtoken",
"msg":"eyJzdGFydF9hdWN0aW9uIjogeyJzdGFydF90aW1lIjogMTY2MzMzNDk3MDIxMSwiZHVyYXRpb24iOiA5MDAwMDAsImNvaW5fZGVub20iOiAidWFuZHIiLCJtaW5fYmlkIjoiMzAwIiwid2hpdGVsaXN0IjogWyJhbmRyMS4uLiIsICJhbmRyMS4uLiIsIC4uLl19fQ=="
}
}
Name
Type
Description
contract
String
The address of the receiving contract.
token_id
String
The id of the token to be sent.
msg
Binary
A message to be sent to the receiving contract.

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
pub enum ExecuteMsg {
Burn {
token_id: String,
},
}
{
"burn": {
"token_id": "1"
}
}
Name
Type
Description
token_id
String
The id of the token to burn.

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
pub enum ExecuteMsg {
Archive {
token_id: String,
}
}
{
"archive": {
"token_id": "1"
}
}
Name
Type
Description
token_id
String
The id of the token to archive.

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
pub enum ExecuteMsg {
Approve {
spender: String,
token_id: String,
expires: Option<Expiration>,
}
}
{
"approve": {
"spender": "andr1...",
"token_id": "1"
}
}
Name
Type
Description
spender
String
The address to be authorised as an operator
token_id
String
The id of the token for which to assign the spender as an operator
expires
Option<Expiration>
An optional expiration for the approval. Defaults to never.

Revoke

A CW721 compliant revoke method. Revokes operator privileges for a given address.
Only available to the token owner/operator.
Rust
JSON
pub enum ExecuteMsg {
Revoke {
spender: String,
token_id: String,
}
}
{
"revoke": {
"spender": "andr1...",
"token_id": "1"
}
}
Name
Type
Description
spender
String
The address of the operator for which to revoke privileges
token_id
String
The id of the token for which to revoke operator privileges

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
pub enum ExecuteMsg {
ApproveAll {
operator: String,
expires: Option<Expiration>,
}
}
{
"approve_all": {
"operator": "andr1..."
}
}
Name
Type
Description
operator
String
The address to be authorised as an operator
expires
Option<Expiration>
An optional expiration for the approval. Defaults to never.

RevokeAll

A CW721 compliant revoke all method. Revokes an operator's privileges for any tokens owned by the sender.
Rust
JSON
pub enum ExecuteMsg {
RevokeAll {
operator: String,
}
}
{
"revoke_all": {
"operator": "andr1..."
}
}
Name
Type
Description
operator
String
The address of the operator for which to revoke privileges.

AndrReceive

Uses the modules feature.

QueryMsg

Minter

Queries the current minter of the contract.
Rust
JSON
pub enum QueryMsg{
#[returns(MinterResponse)]
Minter{},
}
{
"minter":{}
}

MinterResponse

Rust
JSON
pub struct MinterResponse{
minter:String,
}
{
"minter":"andr1..."
}

OwnerOf

A CW721 compliant "owner of" query. Queries the current owner of a given token id.
Rust
JSON
pub enum QueryMsg {
#[returns(OwnerOfResponse)]
OwnerOf {
token_id: String,
include_expired:bool,
}
}
{
"owner_of": {
"token_id": "1",
"include_expired": false
}
}
Name
Type
Description
token_id
String
The id of the token to query.
include_expired
bool
Whether to include any expired owners.

OwnerOfResponse

Rust
JSON
pub struct OwnerOfResponse {
pub owner: String,
pub approvals: Vec<Approval>,
}
{
"owner": "andr1...",
"approvals": [
{
"spender": "andr1...",
"expires": "never"
}
]
}
Name
Type
Description
owner
String
The owner of the queried token.
approvals
An array of all approvals for the token.

Approval

pub struct Approval {
pub spender: String,
pub expires: Expiration,
}
Name
Type
Description
spender
String
The address that is approved.
expires
The expiration for the approval.

AllOperators

A CW721 compliant "approved for all" query. Queries any operators for a given address.
Rust
JSON
pub enum QueryMsg {
#[returns(OperatorsResponse)]
AllOperators {
owner: String,
include_expired: Option<bool>,
start_after: Option<String>,
limit: Option<u32>,
},
{
"all_operators": {
"owner": "andr1...",
"include_expired": true,
"start_after":"andr1...",
"limit": 10
}
}
Name
Type
Description
owner
String
The address of the owner for which to query operators.
include_expired
Option<bool>
Whether to include any expired approvals.
limit
Option<u32>
An optional limit on how many approvals are returned. The default limit is 10 and the maximum limit allowed is 100.
start_after
Option<String>
An optional address for which to start after, used for pagination.

ApprovedForAllResponse

Rust
JSON
pub struct ApprovedForAllResponse {
pub operators: Vec<Approval>,
}