Andromeda
Search…
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 Offers Module is specifically created to work with this contract to facilitate the process of buying/selling the tokens.
In addition to the offers module, the contract has implemented a custom TransferAgreement message to allow the buying/selling of tokens between two parties if the user does not want to add the offers module.
Ado_type: cw721

InstantiateMsg

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub name: String,
pub symbol: String,
pub minter: AndrAddress,
pub modules: Option<Vec<Module>>,
}
{
"name": "Example Token",
"symbol": "ET",
"minter":{
"identifier":"juno1..."
},
"modules": [
{
"module_type": "address_list",
"address": {
"identifier":"juno1..."
}
"is_mutable": false
},
{
...
}
]
}
Name
Type
Description
name
String
The name of the token. Has to be between 3 and 30 characters.
symbol
String
The symbol of the token.
minter
The address of the token minter.
modules
Option<Vec<Module>>
An optional vector of Andromeda Modules that can be attached to the contract. "rates", "address-list", "offers", and "receipt" modules can be added.

ExecuteMsg

Mint

Mints a new NFT, only available to the defined minter in the contract's 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": "juno1...",
"extension": {
"name": "Some token",
"publisher": "juno1...",
"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 ERC721 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": "juno1...",
"extension": {
"name": "Token 1",
"publisher": "juno1...",
"attributes": [],
"archived": false,
"image": "https://pic.onlinewebfonts.com/svg/img_522399.png"
}
},
{
"token_id": "2",
"owner": "juno1...",
"extension": {
"name": "Token 2",
"publisher": "juno1...",
"attributes": [],
"archived": false,
"image": "https://pic.onlinewebfonts.com/svg/img_522399.png"
}
},
{
"token_id": "3",
"owner": "juno1...",
"extension": {
"name": "Token 3",
"publisher": "juno1...",
"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":"ujuno",
"amount":"1000000"
}
},
"purchaser":"juno1..."
}
}
}
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. Only available to the token owner, an approved operator or the purchaser in a TransferAgreement for the given token.
Archived tokens cannot be transferred.
Rust
JSON
pub enum ExecuteMsg {
TransferNft {
recipient: String,
token_id: String,
}
}
{
"transfer_nft": {
"recipient": "juno1...",
"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": "juno1...",
"token_id": "anewtoken",
"msg":""
}
}
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": "anewtoken"
}
}
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": "anewtoken"
}
}
Name
Type
Description
token_id
String
The id of the ADO 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": "juno1...",
"token_id": "anewtoken"
}
}
Name
Type
Description
spender
String
The address to be authorised as an operator
token_id
String
The id of the ADO for which to assign the spender as an operator
expires
Option<Expiration>
An optional expiration for the approval

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": "juno1...",
"token_id": "anewtoken"
}
}
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": "juno1...",
"expires": {
"never": {}
}
}
}
Name
Type
Description
operator
String
The address to be authorised as an operator
expires
Option<Expiration>
An optional expiration for the approval

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": "juno1..."
}
}
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.
pub enum QueryMsg{
Minter{},
}

MinterResponse

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

OwnerOf

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

OwnerOfResponse

Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct OwnerOfResponse {
pub owner: String,
pub approvals: Vec<Approval>,
}
{
"owner": "juno1...",
"approvals": [
{
"spender": "juno1...",
"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 {
AllOperators {
owner: String,
include_expired: bool,
start_after: Option<String>,
limit: Option<u32>,
}
}
{
"all_operators": {
"owner": "juno1...",
"include_expired": true,
"limit": 10
}
}
Name
Type
Description
owner
String
The address of the owner for which to query operators.
include_expired
bool
Whether to include any expired approvals.
limit
Option<u32>
An optional limit on how many approvals are returned.
start_after
Option<String>
An optional address for which to start after, used for pagination.

ApprovedForAllResponse

Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct ApprovedForAllResponse {
pub operators: Vec<Approval>,
}
{
"operators": [
{
"spender": "juno1...",
"expires": {
"never": {}
}
},
...
]
}
Name
Type
Description
approvals
An array of all approvals for the given owner address.

NumTokens

A CW721 compliant "num tokens" query. Queries the amount of tokens minted by the contract.
Rust
JSON
pub enum QueryMsg {
NumTokens {}
}
{
"num_tokens": {}
}

NumTokensResponse

Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct NumTokensResponse {
pub count: u64,
}
{
"count": 1
}
Name
Type
Description
count
u64
The amount of tokens minted by the contract.

NftInfo

A CW721 compliant "nft info" query. Queries the stored info of a token.
Rust
JSON
pub enum QueryMsg {
NftInfo {
token_id: String,
}
}
{
"nft_info": {
"token_id": "anewtoken"
}
}
Name
Type
Description
token_id
String
The id of the token.

NftInfoResponse

Rust
JSON
pub struct NftInfoResponse<T> {
pub token_uri: Option<String>,
pub extension: T,
}
{
"extension":{
"name":"mytoken",
"publisher":"publisher",
"description":"This token ....",
"archived": false
}
}
Name
Type
Description
token_uri
String
Universal resource identifier for this ADO.
extension
T (Generic type)
Any extension being used by the contract.

AllNftInfo

A CW721 compliant "all nft info" query. Queries all stored info of an token.
Rust
JSON
pub enum QueryMsg {
AllNftInfo {
token_id: String,
include_expired: Option<bool>
}
}
{
"all_nft_info": {
"token_id": "anewtoken",
"include_expired": false
}
}
Name
Type
Description
token_id
String
The id of the ADO
include_expired
Option<bool>
Whether to include any expired approvals.

AllNftInfoResponse

Rust
JSON
pub struct AllNftInfoResponse {
pub access: OwnerOfResponse,
pub info: NftInfoResponse,
}
{
"access": {
"owner": "juno1...",
"approvals": [
{
"spender": "juno1...",
"expires": {
"never": {}
}
}
]
},
"info": {
"name": "A New Token",
"description": "A newly minted token",
"extension": {
"archived": false,
"metadata": "{ \"some_json_field\": \"some_json_value\" }",
"agreement": {
"purchaser": "juno1...",
"amount": "100uluna"
}
}
}
}
Name
Type
Description
access
The owner of the ADO and any approvals
info
The given ADO's stored information

IsArchived

Checks if the token with the specified token_id is archived.
Rust
JSON
pub enum QueryMsg {
IsArchived {
token_id: String,
}
}
{
"is_archived":{
"token_id":"3"
}
}
Name
Type
Description
token_id
String
The token_id of the nft we want to check.
Returns a bool value.

TransferAgreement

Checks if the token has a TransferAgreement .
Rust
JSON
pub enum QueryMsg {
TransferAgreement {
token_id: String,
}
}
{
"transfer_agreement":{
"token_id":"3"
}
}
Name
Type
Description
token_id
String
The token_id of the nft we want to check.

Returns None if no TransferAgreement is found, and the TransferAgreement struct otherwise.

Tokens

Queries all the tokens of a particular owner.
Rust
JSON
pub enum QueryMsg {
Tokens {
owner: String,
start_after: Option<String>