Andromeda
Search…
Gumball

Introduction

The Gumball ADO is a smart contract that allows users to buy an NFT randomly from a collection.
The contract can be in 2 different modes:
  • Buying mode: Where people can buy the NFTs from the gumball contract and minting is halted.
  • Minting mode: Where owners can mint new NFTs for the gumball contract and buying is halted.
Upon instantiation, the contract is set to minting mode. To change the mode, we execute SwitchStatus.
Ado_type: gumball

InstantiateMsg

Rust
JSON
pub struct InstantiateMsg {
pub andromeda_cw721_contract: AndrAddress,
pub randomness_source: String,
pub required_coin: String
}
{
"andromeda_cw721_contract":{
"identifier":"juno1..."
},
"randomness_source":"juno1..."
}
Name
Type
Description
andromeda_cw721_contract
The contract address of the NFT contract.
randomness_source
String
The contract address for source of randomness. (Currently using Terrand).
required_coin
String
The denom of the acceptable coin to buy with.

ExecuteMsg

Mint

Mints new tokens from the specified andromeda_cw721_contract to be sold in the gumball contract.
The owner of the tokens should be set as the Gumball contract to be eligible for selling.
More than one NFT can be minted in a single message.
Rust
JSON
pub enum ExecuteMsg {
Mint(Vec<GumballMintMsg>),
}
{
"mint": [{
"token_id": "anewtoken",
"owner": "juno1...",
"extension":{
"name":"mytoken",
"publisher":"publisher",
"description":"This token ....",
"archived": false
},
...
]
}

GumballMintMsg

pub struct GumballMintMsg {
pub token_id: String,
pub owner: Option<String>,
pub token_uri: Option<String>,
pub extension: TokenExtension,
Same as the MintMsg in NFT collectible contract.

Buy

Buy one random NFT.
The gumball status needs to be in buy mode. (Status set to true).
Only one type of funds should be sent which is "uusd" for now.
Rust
JSON
pub enum ExecuteMsg {
Buy {},
}
{
"buy":{}
}

SetSaleDetails

Sets the price of the each token, the maximum amount of tokens that a single address can buy, and the recipient of the funds of the sale.
Only available to the contract owner.
Rust
JSON
pub enum ExecuteMsg {
SetSaleDetails {
price: Coin,
max_amount_per_wallet: Option<Uint128>,
recipient: Recipient,
}
}
{
"set_sale_details":{
"price":{
"denom":"uusd",
"amount":"1000000"
},
"max_amount_per_wallet":"50",
"recipient":{
"addr":"juno1..."
}
}
Name
Type
Description
price
Coin
The price of the token.
max_amount_per_wallet
Option<Uint128>
The amount of tokens a wallet can purchase, defaults to 1.
recipient
Recipient
The recipient of the funds.

SwitchStatus

Automatically switches to opposite status. True means buying is allowed and minting is halted. False means the opposite. The status starts as false.
Only available to the contract owner.
Rust
JSON
pub enum ExecuteMsg {
SwitchStatus {},
}
{
"switch_status":{}
}

UpdateRequiredCoin

Updates the required denom to buy with.
Only available to the contract owner/operator.
Rust
JSON
pub enum ExecuteMsg {
UpdateRequiredCoin {
new_coin: String,
}
}
{
"update_required_coin":{
"new_coin":"ujunox"
}
}
Name
Type
Description
new_coin
String
The new denom that can be used to purchase NFTs.

AndrReceive

QueryMsg

NumberOfNfts

Queries the number of tokens currently available for purchase.
Rust
JSON
pub enum QueryMsg {
NumberOfNfts {},
}
{
"number_of_nfts":{}
}

NumberOfNftsResponse

Rust
JSON
pub struct NumberOfNFTsResponse {
pub number: usize,
}
{
"number": 5
}
Name
Type
Description
number
usize
The number of tokens available for purchase.

SaleDetails

Gets the sale details which are set by executing SetSaleDetails.
Rust
JSON
pub enum QueryMsg {
SaleDetails {},
}
{
"sale_details":{}
}

SaleDetailsResponse

Rust
JSON
pub struct State {
pub price: Coin,
pub max_amount_per_wallet: Uint128,
pub recipient: Recipient,
}
{
"price":{
"denom":"uusd",
"amount":"1000000"
},
"max_amount_per_wallet":"50",
"recipient":{
"addr":"juno1..."
}
}
Name
Type
Description
price
Coin
The price of each token.
max_amount_per_wallet
Uint128
The max number o tokens allowed per wallet.
recipient
Recipient
The recipient of the funds upon sale.

Status

Rust
JSON
pub enum QueryMsg {
Status {}
}
{
"status":{}
}

StatusResponse

Rust
JSON
pub struct StatusResponse {
pub status: bool,
}
{
"status": true
}
Name
Type
Description
status
bool
True if in buying mode. False if minting mode. Starts as false.

AndrQuery

Check AndrQuery.
Copy link
Outline
Introduction
InstantiateMsg
ExecuteMsg
Mint
Buy
SetSaleDetails
SwitchStatus
UpdateRequiredCoin
AndrReceive
QueryMsg
NumberOfNfts
SaleDetails
Status
AndrQuery