(mint (all-token-data {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}))
The most fundamental mint
function. Takes in a tuple all-token-data
that contains all necesarry information for minting. The function calculates royalties, populates the relevant data maps, and mints the token to the minter
principal with token-id
token ID. All other mint
functions call this one.
all-token-data
: tuple:token-id
: uintminter
: principalmetadata
: string-ascii 256data
: tuple:price
: uintfor-sale
: bool
royalties
: optional list of up to 5 royalty tuples:address
: principalpercentage
: uint
- On success:
token-id
- On error:
error-id
(mint-transfer (file {all-token-data: {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}, recipient: principal}))
Mints and immediately tranfsers NFT. Accepts all-token-data
tuple and calls the mint
function. Upon successful mint transfers NFT to recipient
.
file
: tuple:all-token-data
: tuple (seemint
params)recipient
: principal
- On success:
token-id
- On error:
error-id
(mint-pay (file {all-token-data: {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}, buyer: principal}))
Mints and immediately executes the purchase flow. Accepts all-token-data
tuple and calls the mint
function. Upon successful mint executes pay-transfer
flow which transfers STX from admin to minter
argument and transfers the minted NFT from minter
to buyer
. (Note pay-transfer
function automatically changes for-sale
bool in token-data
map to false
)
file
: tuple:all-token-data
: tuple (seemint
params)buyer
: principal
- On success:
token-id
- On error:
error-id
(mint-admin (file {all-token-data: {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}, post-mint: (optional {recipient: principal, is-purchase: bool})}))
Function that depending on the arguments will call one of mint
, mint-transfer
, or mint-pay
functions. Information about the NFT is supplied by the all-token-data
argument. post-mint
argument provides information about which minting flow to execute:
- No
post-mint
tuple (none
provided in argument) will only mint NFT by invoking themint
function. post-mint
provided, withis-purchase
set tofalse
will invoke themint-transfer
flow.post-mint
provided, withis-purchase
set totrue
will invoke themint-pay
flow.
file
: tuple:all-token-data
: tuple (seemint
params)post-mint
: optional tuple:recipient
: principalis-purchase
: bool
- On success:
token-id
- On error:
error-id
(mint-edition (token-id uint) (all-token-data (response {minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))} uint)))
Essentially just mints the NFT, same as mint
function, but tailored for mint-editions
flow. For more info see mint-editions
function descripiton.
token-id
: uintall-token-data
: response tuple (seemint
params) uint
- On success:
token-id
- On error:
error-id
(mint-many (files (list 500 {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))})))
Callable only by admin. Takes a list of up to 500 all-token-data
tuples and attempts to mint each one. Returns a list of responses corresponding to each mint
function invokation to provide info on whether a particular attempt to mint failed or was successful.
files
: list of up to 500 tuples:- Tuple corresponds to params of the
mint
function. Seeall-token-data
tuple description inmint
function params.
- Tuple corresponds to params of the
List of responses from each mint
call. Successful mints return (ok token-id
). Failed mints return (err error-id
).
(mint-transfer-many (files (list 500 {all-token-data: {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}, recipient: principal})))
Callable only by admin. Same as mint-many
function but invokes mint-transfer
function for each tuple in the list.
files
: list of up to 500 tuples:- Tuple corresponds to params of the
mint-transfer
function.
- Tuple corresponds to params of the
List of responses from each mint-transfer
call. Successful mints return (ok token-id
). Failed mints return (err error-id
).
(mint-pay-many (files (list 500 {all-token-data: {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}, buyer: principal})))
Callable only by admin. Same as mint-many
function but invokes mint-pay
function for each tuple in the list.
files
: list of up to 500 tuples:- Tuple corresponds to params of the
mint-pay
function.
- Tuple corresponds to params of the
List of responses from each mint-pay
call. Successful mints return (ok token-id
). Failed mints return (err error-id
).
(mint-admin-many (files (list 500 {all-token-data: {token-id: uint, minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}, post-mint: (optional {recipient: principal, is-purchase: bool})})))
Callable only by admin. Same as mint-many
function but invokes mint-admin
function for each tuple in the list.
files
: list of up to 500 tuples:- Tuple corresponds to params of the
mint-admin
function.
- Tuple corresponds to params of the
List of responses from each mint-admin
call. Successful mints return (ok token-id
). Failed mints return (err error-id
).
(mint-editions (edition-ids (list 10000 uint)) (all-token-data {minter: principal, metadata: (string-ascii 256), data: {price: uint, for-sale: bool}, royalties: (optional (list 5 {address: principal, percentage: uint}))}))
Callable only by admin. Accepts a list of up to 10000 token IDs and one all-token-data
tuple. For each token ID the function will mint a new NFT with data supplied by all-token-data
tuple.
edition-ids
: list of up to 10000 uint:all-token-data
: tuple (seemint
params)
List of responses from each mint-edition
call. Successful mints return (ok token-id
). Failed mints return (err error-id
).
(pay (token-id uint) (token-price uint) (token-owner principal))
Internal function that retrieves royalties and owner's share from contract maps and pays those percentages out from tx-sender based on the token price supplied in the argument. Owner percentage is paid out to the provided token-owner
argument.
token-id
: uinttoken-price
: uinttoken-owner
: principal
- On success:
token-id
- On error:
error-id
(pay-transfer (token-id uint) (token-price uint) (token-owner principal) (token-recipient principal))
Internal function that transfers an NFT from tx-sender
to token-recipient
and then invokes the pay
internal function.
token-id
: uinttoken-price
: uinttoken-owner
: principaltoken-recipient
: principal
- On success:
token-id
- On error:
error-id
(complete-sale (sale-datum {token-id: uint, token-owner: principal, token-recipient: (optional principal), token-price: uint}))
Internal function that completes a sale. If no token-recipient
argument is supplied then it executes the pay
function. If one is supplied, then pay-transfer
is executed.
sale-datum
: tuple:token-id
: uinttoken-owner
: principaltoken-recipient
: optional principaltoken-price
: uint
- On success:
token-id
- On error:
error-id
(complete-sale-many (sale-data (list 500 {token-id: uint, token-owner: principal, token-recipient: (optional principal), token-price: uint})))
Callable only by admin. Accepts a list of up to 500 sale-datum
arguments and calls the complete-sale
function for each one and returns a list of call responses.
sale-data
: list 500 tuples:- Tuple corresponds to params of the
complete-sale
function.
- Tuple corresponds to params of the
List of responses from each complete-sale
call. Successful calls return (ok token-id
). Failed mints return (err error-id
)
(purchase (token-id uint))
Executes the purchase flow if the token specified to token-id
is set as for-sale
. Tx-sender pays token-owner and royalties and in turn receives the NFT associated to the token-id
. Note: all successful purchases automatically set for-sale
to false
.
token-id
: uint
- On success:
true
- On error:
error-id
(lock-stx-in-escrow (token-id uint) (price uint) (memo (string-ascii 100)))
Funciton necessary for completing STX purchases for lazy-minted NFTs. Transfers price
amount from tx-sender to admin. This will in turn trigger the mint-pay
flow in heylayer's backend which is called by admin.
token-id
: uintprice
: uintmemo
: string-ascii 100
- On success:
token-id
- On error:
error-id
(transfer (token-id uint) (owner principal) (recipient principal))
SIP-009 function that will transfer token-id
from owner
to recipient
. Only executes if tx-sender
is equal to owner
argument and is the owner returned by the internal nft-get-owner?
function. Note: successful transfers automatically set for-sale
to false
.
token-id
: uintowner
: principalrecipient
: principal
- On success:
true
- On error:
error-id
(transfer-many (transfer-data (list 500 {token-id: uint, recipient: principal})))
Accepts a list of up to 500 tuples and calls the transfer
function for each one and returns a list of call responses. Useful for transferring multiple NFTs in one call. owner
argument that is eventually passed to the transfer
function is always tx-sender
.
transfer-data
: list of 500 tuples:token-id
: uintrecipient
: principal Note: params don't directly correspond to thetransfer
function because of the format specified in SIP-009, so an internal helper functiontransfer-many-helper
desctructures the tuple totransfer
function compliant arguments.
List of responses from each transfer
call. Successful calls return (ok true
). Failed mints return (err error-id
)
(set-token-price-data (token-id uint) (price uint) (for-sale bool))
Only callable by token-owner. Populates the token-data
map entry associated with token-id
with the provided price
and for-sale
params.
token-id
: uintprice
: uintfor-sale
: bool
- On success:
true
- On error:
error-id
(transfer-stx (transfer-datum {amount: uint, recipient: principal, memo: (optional (string-ascii 100))}))
Transfers STX worth amount
from tx-sender
to recipient
and prints the optional memo
arg.
transfer-datum
: tupleamount
: uintrecipient
: principalmemo
: optional string-ascii 100
- On success:
amount
- On error:
error-id
(transfer-stx-many (transfer-data (list 500 {amount: uint, recipient: principal, memo: (optional (string-ascii 100))})))
Wrapper function that does multiple transfer-stx
invocations in one call.
transfer-data
: list of up to 500trasnfer-datum
tuples- Tuples correspond to params of the
transfer-stx
function.
- Tuples correspond to params of the
List of responses from each transfer-stx
call. Successful calls return (ok amount
). Failed mints return (err error-id
)
(delete-token (token-id uint))
Only callable by admin. If admin is owner of the NFT the the token gets deleted and all of its associated map entries are erased.
token-id
: uint
- On success:
token-id
- On error:
error-id
(delete-token-many (token-ids (list 500 uint)))
Wrapper function that does multiple delete-token
invocations in one call.
token-ids
: list of up to 500 uints
List of responses from each delete-token
call. Successful calls return (ok token-id
). Failed mints return (err error-id
)
(change-admin (new-admin principal))
(set-admin-fee (fee uint))
(validate-auth (challenge-token (string-ascii 500))) (ok true))