A prefix to use for every key of this map
Get number of tokens tracked in the contract
Basic usage example:
Assume contract has 9450 tokens,
const persistent_tokens = new PersistentTokens('pt')
const tokens_length = persistent_tokens.number_of_tokens();
log(parseInt(tokens_length)) // 9450
Number of tokens present in the contract in u128
format
Add a new token to the contract
Basic usage example:
Assume we need add the token T1
to the contract, and it owns by the user with account id = alice.test.near
,
const persistent_tokens = new PersistentTokens('pt')
const token = persistent_tokens.add('alice_23456' , T1 , "alice.test.near");
Id of the new token
Token to be saved to the contract
ID of the account that owns the token
Saved token
Burn a token from the contract
Basic usage example:
Assume we need burn the token with token id = alice_23456
from the contract,
const persistent_tokens = new PersistentTokens('pt')
persistent_tokens.burn('alice_23456' , "alice.test.near");
Id of the token to burn
ID of the account that owns the burning token
Get token details of a single token
Basic usage example:
Assume we need to get the details of the token with token id = jenny911038
,
const persistent_tokens = new PersistentTokens('pt')
const token = persistent_tokens.get("jenny911038");
ID of token to retrieve from _map
Token details object
Check if the relevant token exists or not
Basic usage example:
Assume we need to check if the token with token id = jenny911038
present in the storage,
const persistent_tokens = new PersistentTokens('pt')
const is_token_exists = persistent_tokens.has("jenny911038");
ID of the token to check it's exists or not
true if token exits, false if not
Get the IDs of tokens saved in the provided range
Basic usage example:
Assume we need the IDs of first 5 tokens,
const persistent_tokens = new PersistentTokens('pt')
const token_ids = persistent_tokens.keys(0, 5);
Start index
End index
An array of tokenIds
Remove a token from a user's token set
Basic usage example:
Assume we need remove the token with token id = alice_23456
from the user with account id = alice.test.near
,
const persistent_tokens = new PersistentTokens('pt')
persistent_tokens.remove('alice_23456' , "alice.test.near");
Id of the token to remove from
ID of the account that owns the removing token
Get number of tokens saved in the contract for a given account
Basic usage example:
Assume user with account id = alice.test.near
has 12 tokens in the contract,
const persistent_tokens = new PersistentTokens('pt')
const tokens_length_for_user = persistent_tokens.supply_for_owner("alice.test.near");
log(tokens_length_for_user) // "12"
ID of the account to retrieve number of tokens that account owns
Number of tokens present for the given account in the contract
Get the IDs of tokens saved in the contract for a given account/user
Basic usage example:
Assume we need the IDs of the tokens that user with account id = alice.test.near
owns,
const persistent_tokens = new PersistentTokens('pt')
const token_ids_for_user = persistent_tokens.tokens_for_owner("alice.test.near");
ID of the account to retrieve token IDs of the tokens that account/user owns
An array of tokenIds that the given account/user owns
Generated using TypeDoc