ID of the token that need to accept the bid
ID of the bidder that owner would like to accept the bid
Check to see if the attached deposit is at least 1 yoctoNEAR or not. If not, it throws an error.
Check to see if the attached deposit is equal to the required amount or not. If not, it throws an error.
Amount required in u128
format.
Check to see if the given owner of the token has signed the transaction or not. If not, it throws an error.
ID of the account who signed the transaction
ID of the account who owns the token
Check to see if the given account ID has tokens more than the given number or not. If exceeded, it throws an error.
Maximum number of tokens allowed for one account
ID of the account to check if it has more than allowed number of tokens
Check to see if the contract is paused or not. If paused, it throws an error.
Check to see if the attached deposit is exactly 1 yoctoNEAR or not. If not, it throws an error.
Check to see if the given token ID has a token associated with it or not. If not, it throws an error.
ID of the token to check it exists or not
Burn a token
burn_design
won't completely remove the token
from the contract
. Instead of that, it will remove the owner details from the token and the contract for that respective token. So token metadata can be found and token details except owner_id
can be found in the contract. But any of the change methods won't work for that token other than remove_bid
method. Users can remove their bid made for that token even after it's burned.
Note: In order to burn a token, user must be the creator and the owner of the token
Basic usage example:
Assume we need to burn a token with the token id = jenny911038
,
burn_design("jenny911038");
ID of the token that needs to burn
Get bids set by a particular user.
Basic usage example:
Assume we need to get all the bids that set by a user with account id = alice.test.near
,
const bids_by_user = get_bidder_bids("alice.test.near");
ID of the user that need to get the bids set by him
Array of bids that user has
Get bids for a particular token.
Basic usage example:
Assume we need to get all the bids on a token with a token id = jenny911038
,
const bids_for_the_token = get_bids("jenny911038");
ID of the token that need to get the bids
Object of the bids that the token has
Initialize the contract with owner details, standard metadata and extra metadata.
Note: This function can be called only once, and it should be called immediately after deploying the contract.
Basic usage example:
Assume we need to initialize the contract with owner_id = alice.test.near
and standard metadata details object MTS1
and extra metadata details object MTE1
,
init( "alice.test.near", MTS1, MTE1 );
ID of the contract owner
Standard metadata object of the contract
Extra metadata object of the contract
Check if the given account ID is approved to perform a transfer behalf of the owner of the particular token
Note: This is used as an internal function.
Basic usage example:
Assume we need to check that a user with account id = alice.test.near
, is approved to perform the transfer for a token with the token id = jenny911038
and owner_Id = jenny.test.near
,,
const is_approved = internal_nft_is_approved("jenny911038", "alice.test.near" ,1);
console.log(is_approved); // true | false
ID of the token
ID of the account that need check whether it is approved or not for the given token
Approval ID number for the given approved_account_id
Whether the account is approved or not
Get payout object for a particular token based on a given balance.
Note: This is used as a internal function.
Basic usage example:
Assume we need to payout 1 NEAR
for the first 5 royalties in token with token id = jenny911038
,
const balance = u128.from(1)
const payout = internal_nft_payout("jenny911038", balance, 5);
ID of the token that need to get the bids
Amount to pay for the payout royalties in u128
format
Maximum number of royalties for the token
Royalty payout object
Mint a new token.
Note: mint
function will need an attached deposit equal to mint_price
specified in the contract extra metadata
.
Basic usage example:
const token_metadata = new TokenMetadata()
token_metadata.title = 'sample title'
token_metadata.media = 'sample media'
...
const token_royalty = new TokenRoyalty()
token_royalty.percentage = 2500
token_royalty.split_between.set('alice.test.near', 2500)
...
const token = mint(token_metadata, token_royalty);
Metadata object of the minted token
Royalty object of the minted token
Minted token
Check if the given account ID is approved to perform a transfer behalf of the owner of the particular token
Basic usage example:
Assume we need to check that a user with account id = alice.test.near
, is approved to perform the transfer for a token with the token id = jenny911038
and owner_Id = jenny.test.near
,,
const is_approved = nft_is_approved("jenny911038", "alice.test.near" ,1);
console.log(is_approved); // true | false
ID of the token
ID of the account that need check whether it is approved or not for the given token
Approval ID number for the given approved_account_id
Whether the account is approved or not
Get Standard Metadata of the contract.
Basic usage example:
const metadata = nft_metadata();
Standard metadata details of the Contract
Get Extra Metadata of the contract.
Basic usage example:
const extra_metadata = nft_metadata_extra();
Extra metadata details of the Contract
Get payout object for a particular token based on a given balance.
Basic usage example:
Assume we need to payout 1 NEAR
for the first 5 royalties in token with token id = jenny911038
,
const balance = u128.from(1)
const payout = internal_nft_payout("jenny911038", balance, 5);
ID of the token that need to get the bids
Amount to pay for the payout royalties in u128
format
Maximum number of royalties for the token
Royalty payout object
Get total number of tokens that a particular user owns.
Basic usage example:
Assume alice.test.near
account owns 10 tokens,
const total_no_of_tokens = nft_supply_for_owner("alice.test.near");
console.log(total_no_of_tokens); // "10"
ID of the user
Total number of tokens that user owns
Get details of a single token
Basic usage example:
Assume we need to get details of a token with the token id = jenny911038
,
let token = nft_token("jenny911038");
ID of the token that needs to get details
Details of the token if present
Get all tokens within a range.
Basic usage example:
Assume we need to get the first 4 tokens,
const tokens = nft_tokens("0", 4);
Starting index
Number of tokens needs to be fetched starting from from_index
Array of tokens within the range specified by from_index
and limit
Get tokens that a particular user owns within a range.
Basic usage example:
Assume we need to get the first 4 tokens that alice.test.near
account owns,
const tokens_for_owner = nft_tokens_for_owner("alice.test.near", "0", 4);
Account ID of the user
Starting index
Number of tokens needs to be fetched starting from from_index
Array of tokens that user owns
Get total number of tokens registered in this contract.
Basic usage example:
Assume the contract has 9999 tokens registered in it,
const total = nft_total_supply();
console.log(total); // "9999"
Total number of tokens registered in this contract
Transfer a token to another account
Note: User must be the owner of the token
Basic usage example:
Assume we need to transfer a token with the token id = jenny911038
to a user with account id = alice.test.near
,
nft_transfer("jenny911038", "alice.test.near");
ID of the token that needs to transfer
ID of the receiving account
Remove the sender bid from a particular token
Basic usage example:
Assume we set a bid worth of 1 NEAR to the token jenny911038
. And then we need to remove that bid from the token.
Note: Since the account id affected is always the context.sender
, we just need to provide only the token id
remove_bid("jenny911038");
ID of the token to remove the bid from
Get the amount that need to pay for a royalty account when the token value and royalty percentage is given. Return value is in u128
format.
Percentage of the token value to calculate amount
Total amount to calculate percentage on
Payout in u128
format
Set a bid on a particular token.
Basic usage example:
Assume we need to set a bid to the token with id = jenny911038
,
const bid = new Bid();
bid.amount = u128.from(1)
bid.bidder = 'alice.test.near'
bid.recipient = "jenny911038"
bid.sell_on_share = 10
bid.currency = 'near'
const setted_bid = set_bid(
"jenny911038",
bid
);
ID of the token that need to set a bid
Bid that need set to the token
The bid that set to the token
Pause the contract change methods, if the owner wants to do that due to some reasons.
Note: This function can be called only by the owner account or the contract account itself.
Basic usage example:
Assume that the owner need to pause the contract,
set_paused( true );
Whether to pause the contract or not
Current state of the contract
Generated using TypeDoc
Accept a certain bid on a particular token.
Note: Only the owner of the token can accept a bid
Basic usage example:
Assume the owner of the token with id =
jenny911038
need to accept a bid that set by a user with account id =alice.test.near
,accept_bid("jenny911038", "alice.test.near");