Options
All
  • Public
  • Public/Protected
  • All
Menu

curaOS/Contracts

Index

Type aliases

BidsByBidder

BidsByBidder: Map<TokenId, Bid>

Variables

Const persistent_market

persistent_market: PersistentMarket = new PersistentMarket('pm')

Const persistent_nft_contract_metadata

persistent_nft_contract_metadata: PersistentNFTContractMetadata = new PersistentNFTContractMetadata()

Const persistent_tokens

persistent_tokens: PersistentTokens = new PersistentTokens('pt')

Const persistent_tokens_metadata

persistent_tokens_metadata: PeristentTokenMetadata = new PeristentTokenMetadata('ptm')

Const persistent_tokens_royalty

persistent_tokens_royalty: PeristentTokenRoyalty = new PeristentTokenRoyalty('ptr')

Functions

accept_bid

  • accept_bid(tokenId: string, bidder: string): void
  • 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");
    

    Parameters

    • tokenId: string

      ID of the token that need to accept the bid

    • bidder: string

      ID of the bidder that owner would like to accept the bid

    Returns void

assert_at_least_one_yocto

  • assert_at_least_one_yocto(): void
  • Check to see if the attached deposit is at least 1 yoctoNEAR or not. If not, it throws an error.

    Returns void

assert_eq_attached_deposit

  • assert_eq_attached_deposit(amount: u128): void
  • Check to see if the attached deposit is equal to the required amount or not. If not, it throws an error.

    Parameters

    • amount: u128

      Amount required in u128 format.

    Returns void

assert_eq_token_owner

  • assert_eq_token_owner(predecessor: AccountId, owner_id: AccountId): void
  • Check to see if the given owner of the token has signed the transaction or not. If not, it throws an error.

    Parameters

    • predecessor: AccountId

      ID of the account who signed the transaction

    • owner_id: AccountId

      ID of the account who owns the token

    Returns void

assert_mints_per_address

  • assert_mints_per_address(mints_per_address: u32, address: AccountId): void
  • Check to see if the given account ID has tokens more than the given number or not. If exceeded, it throws an error.

    Parameters

    • mints_per_address: u32

      Maximum number of tokens allowed for one account

    • address: AccountId

      ID of the account to check if it has more than allowed number of tokens

    Returns void

assert_not_paused

  • assert_not_paused(): void
  • Check to see if the contract is paused or not. If paused, it throws an error.

    Returns void

assert_one_yocto

  • assert_one_yocto(): void
  • Check to see if the attached deposit is exactly 1 yoctoNEAR or not. If not, it throws an error.

    Returns void

assert_token_exists

  • assert_token_exists(token_id: TokenId): void
  • Check to see if the given token ID has a token associated with it or not. If not, it throws an error.

    Parameters

    • token_id: TokenId

      ID of the token to check it exists or not

    Returns void

burn_design

  • burn_design(token_id: TokenId): void
  • 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");
    

    Parameters

    • token_id: TokenId

      ID of the token that needs to burn

    Returns void

get_bidder_bids

  • get_bidder_bids(accountId: string): Bid[]
  • 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");
    

    Parameters

    • accountId: string

      ID of the user that need to get the bids set by him

    Returns Bid[]

    Array of bids that user has

get_bids

  • 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");
    

    Parameters

    • tokenId: string

      ID of the token that need to get the bids

    Returns BidsByBidder

    Object of the bids that the token has

init

  • 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 );
    

    Parameters

    • owner_id: AccountId

      ID of the contract owner

    • contract_metadata: NFTContractMetadata

      Standard metadata object of the contract

    • Default value contract_extra: NFTContractExtra = defaultNFTContractExtra()

      Extra metadata object of the contract

    Returns void

internal_nft_is_approved

  • internal_nft_is_approved(token_id: TokenId, approved_account_id: AccountId, approval_id?: string | null): boolean
  • 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
    

    Parameters

    • token_id: TokenId

      ID of the token

    • approved_account_id: AccountId

      ID of the account that need check whether it is approved or not for the given token

    • Default value approval_id: string | null = null

      Approval ID number for the given approved_account_id

    Returns boolean

    Whether the account is approved or not

internal_nft_payout

  • internal_nft_payout(token_id: TokenId, balance: u128, max_len_payout?: u32): Payout | null
  • 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);
    

    Parameters

    • token_id: TokenId

      ID of the token that need to get the bids

    • balance: u128

      Amount to pay for the payout royalties in u128 format

    • Default value max_len_payout: u32 = 0

      Maximum number of royalties for the token

    Returns Payout | null

    Royalty payout object

mint

  • 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);
    

    Parameters

    • tokenMetadata: TokenMetadata

      Metadata object of the minted token

    • token_royalty: TokenRoyalty

      Royalty object of the minted token

    Returns Token

    Minted token

nft_is_approved

  • nft_is_approved(token_id: TokenId, approved_account_id: AccountId, approval_id?: string | null): boolean
  • 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
    

    Parameters

    • token_id: TokenId

      ID of the token

    • approved_account_id: AccountId

      ID of the account that need check whether it is approved or not for the given token

    • Default value approval_id: string | null = null

      Approval ID number for the given approved_account_id

    Returns boolean

    Whether the account is approved or not

nft_metadata

  • Get Standard Metadata of the contract.

    Basic usage example:

    const metadata = nft_metadata();
    

    Returns NFTContractMetadata

    Standard metadata details of the Contract

nft_metadata_extra

  • Get Extra Metadata of the contract.

    Basic usage example:

    const extra_metadata = nft_metadata_extra();
    

    Returns NFTContractExtra

    Extra metadata details of the Contract

nft_payout

  • nft_payout(token_id: TokenId, balance: u128, max_len_payout?: u32): Payout | null
  • 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);
    

    Parameters

    • token_id: TokenId

      ID of the token that need to get the bids

    • balance: u128

      Amount to pay for the payout royalties in u128 format

    • Default value max_len_payout: u32 = 0

      Maximum number of royalties for the token

    Returns Payout | null

    Royalty payout object

nft_supply_for_owner

  • nft_supply_for_owner(account_id: string): string
  • 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"
    

    Parameters

    • account_id: string

      ID of the user

    Returns string

    Total number of tokens that user owns

nft_token

  • nft_token(token_id: TokenId): Token
  • 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");
    

    Parameters

    • token_id: TokenId

      ID of the token that needs to get details

    Returns Token

    Details of the token if present

nft_tokens

  • nft_tokens(from_index?: string, limit?: u8): Token[]
  • Get all tokens within a range.

    Basic usage example:

    Assume we need to get the first 4 tokens,

    const tokens = nft_tokens("0", 4);
    

    Parameters

    • Default value from_index: string = "0"

      Starting index

    • Default value limit: u8 = 0

      Number of tokens needs to be fetched starting from from_index

    Returns Token[]

    Array of tokens within the range specified by from_index and limit

nft_tokens_for_owner

  • nft_tokens_for_owner(account_id: string, from_index?: string, limit?: u8): Token[]
  • 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);
    

    Parameters

    • account_id: string

      Account ID of the user

    • Default value from_index: string = "0"

      Starting index

    • Default value limit: u8 = 0

      Number of tokens needs to be fetched starting from from_index

    Returns Token[]

    Array of tokens that user owns

nft_total_supply

  • nft_total_supply(): string
  • 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"
    

    Returns string

    Total number of tokens registered in this contract

nft_transfer

  • nft_transfer(token_id: TokenId, receiver_id: AccountId): void
  • 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");
    

    Parameters

    • token_id: TokenId

      ID of the token that needs to transfer

    • receiver_id: AccountId

      ID of the receiving account

    Returns void

remove_bid

  • remove_bid(tokenId: string): void
  • 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");
    

    Parameters

    • tokenId: string

      ID of the token to remove the bid from

    Returns void

royalty_to_payout

  • royalty_to_payout(royalty_percentage: u32, amount_to_pay: Balance): u128
  • 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.

    Parameters

    • royalty_percentage: u32

      Percentage of the token value to calculate amount

    • amount_to_pay: Balance

      Total amount to calculate percentage on

    Returns u128

    Payout in u128 format

set_bid

  • set_bid(tokenId: string, bid: Bid): Bid
  • 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
    );
    

    Parameters

    • tokenId: string

      ID of the token that need to set a bid

    • bid: Bid

      Bid that need set to the token

    Returns Bid

    The bid that set to the token

set_paused

  • set_paused(value?: boolean): boolean
  • 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 );
    

    Parameters

    • Default value value: boolean = true

      Whether to pause the contract or not

    Returns boolean

    Current state of the contract

Generated using TypeDoc