Skip to content

Latest commit

 

History

History

mg-nft

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Contract

This module implements the NFT contract for the MintGate marketplace. The MintGate marketplace consists of two main entities:

  • Collectibles
  • Tokens

A Collectible represents a content that a creator wants to tokenize. A Token represents a copy of a given Collectible.

In addition, this contract implements the following NFT standards:

Methods for NftContract

🚀 init (constructor)

init: { admin_id: ValidAccountId, metadata: NFTContractMetadata, min_royalty: Fraction, max_royalty: Fraction, mintgate_fee: Fraction, mintgate_fee_account_id: ValidAccountId };

Initializes the contract. This contract methods needs to be explicitely called since the default construction of the contract will panic.

  • admin_id is the valid account that is allowed to perform certain operations.
  • metadata represents the general information of the contract.
  • min_royalty and max_royalty indicates what must be the max and min royalty respectively when creating a collectible.
  • mintgate_fee is the percetange to be paid to mintgate_fee_account_id for each sale.

✍️ create_collectible

create_collectible(args: { creator_id: ValidAccountId, gate_id: ValidGateId, title: string, description: string, supply: number, royalty: Fraction, media: string|null, media_hash: string|null, reference: string|null, reference_hash: string|null }, gas?: any): Promise<void>;

Creates a new Collectible, identified by gate_id. The supply indicates maximum supply for this collectible. The royalty indicates the royalty (as percentage) paid to the creator (predecessor_account_id). This royalty is paid when any Token is being resold in any marketplace.

The sum of royalty and mintgate_fee should be less than 1. Panics otherwise. This is to be able to make payouts all participants.

See epam/mintgate#3.

👓 get_collectible_by_gate_id

get_collectible_by_gate_id(args: { gate_id: ValidGateId }): Promise<Collectible|null>;

Returns the Collectible with the given gate_id. Panics otherwise.

See epam/mintgate#16.

👓 get_collectibles_by_creator

get_collectibles_by_creator(args: { creator_id: ValidAccountId }): Promise<Collectible[]>;

Returns all Collectibles created by creator_id.

See epam/mintgate#15.

✍️ delete_collectible

delete_collectible(args: { gate_id: ValidGateId }, gas?: any): Promise<void>;

Deletes the given Collectible by gate_id. The collectible can only be deleted if there are no minted tokens. Moreover, only the creator_id of the collectible or the contract admin_id are allowed to delete the collectible.

✍️ claim_token

claim_token(args: { gate_id: ValidGateId }, gas?: any): Promise<TokenId>;

Claims a Token for the Collectible indicated by gate_id. The claim is on behalf the predecessor_account_id. Returns a TokenId that represents this claim. If the given gate_id has exhausted its supply, this call will panic.

See epam/mintgate#6.

✍️ burn_token

burn_token(args: { token_id: TokenId }, gas?: any): Promise<void>;

Burns (deletes) the Token identifed by token_id. Only the owner_id can burn the token.

After succefully delete the token, a cross-contract call is made to nft_on_revoke for each approval to delist from their marketplaces.

👓 get_tokens_by_owner

get_tokens_by_owner(args: { owner_id: ValidAccountId }): Promise<Token[]>;

Returns all Tokens owned by owner_id.

👓 get_tokens_by_owner_and_gate_id

get_tokens_by_owner_and_gate_id(args: { gate_id: ValidGateId, owner_id: ValidAccountId }): Promise<Token[]>;

Returns all tokens claimed by owner_id belonging to gate_id.

See epam/mintgate#14.

✍️ batch_approve

batch_approve(args: { tokens: [TokenId, U128][], account_id: ValidAccountId }, gas?: any): Promise<void>;

Approves a batch of tokens, similar to nft_approve. Each approval contains the TokenId to approve and the minimum price to sell the token for. account_id indicates the market account contract where list these tokens.

Methods for NonFungibleTokenCore interface

✍️ nft_transfer

nft_transfer(args: { receiver_id: ValidAccountId, token_id: TokenId, enforce_approval_id: U64|null, memo: string|null }, gas?: any): Promise<void>;

Transfer the token token_id to the receiver_id account.

See epam/mintgate#18.

👓 nft_payout

nft_payout(args: { token_id: TokenId, balance: U128 }): Promise<Payout>;

Query whom to be paid out for a given token_id, derived from some balance. For example, given the following settings for the NFT contract and collectible gate_id:

  • mintgate_fee: 25/1000 (2.5%)
  • royalty: 30/100 (30%)

Then nft_payout(token_id, 5_000_000) will return

  • mintgate_fee_account_id -> 125_000
  • collectible.creator_id -> 3_375_000
  • token.owner_id -> 1_500_000

for any token_id claimed from gate_id.

This is part of an ongoing (yet not settled) NEP spec: https://github.com/thor314/NEPs/blob/patch-5/specs/Standards/NonFungibleToken/payouts.md

✍️ nft_transfer_payout

nft_transfer_payout(args: { receiver_id: ValidAccountId, token_id: TokenId, approval_id: U64|null, memo: string|null, balance: U128|null }, gas?: any): Promise<Payout|null>;

Attempts to transfer the token. Afterwards returns the payout data. Effectively it is calling nft_transfer followed by nft_payout.

This is part of an ongoing (yet not settled) NEP spec: https://github.com/thor314/NEPs/blob/patch-5/specs/Standards/NonFungibleToken/payouts.md

👓 nft_token

nft_token(args: { token_id: TokenId }): Promise<Token|null>;

Returns the token identified by token_id. Or null if the token_id was not found.

See epam/mintgate#17.

Methods for NonFungibleTokenMetadata interface

👓 nft_metadata

nft_metadata(): Promise<NFTContractMetadata>;

Returns the NFT metadata for this contract.

Methods for NonFungibleTokenApprovalMgmt interface

✍️ nft_approve

nft_approve(args: { token_id: TokenId, account_id: ValidAccountId, msg: string|null }, gas?: any): Promise<void>;

Allows account_id to transfer token_id on behalf of its owner. The msg argument allows the caller to pass into additional information. A contract implementing the nft_on_approve methods must be deployed into account_id.

✍️ nft_revoke

nft_revoke(args: { token_id: TokenId, account_id: ValidAccountId }, gas?: any): Promise<void>;

Revokes approval for token_id from account_id.

✍️ nft_revoke_all

nft_revoke_all(args: { token_id: TokenId }, gas?: any): Promise<void>;

Revokes all approval for token_id.

Methods for NonFungibleTokenEnumeration interface

👓 nft_total_supply

nft_total_supply(): Promise<U64>;

Returns the total token supply.

👓 nft_tokens

nft_tokens(args: { from_index: U64|null, limit: number|null }): Promise<Token[]>;

Returns all or paginated Tokens minted by this contract. Pagination is given by:

  • from_index the index to start fetching tokens.
  • limit indicates how many tokens will be at most returned.

👓 nft_supply_for_owner

nft_supply_for_owner(args: { account_id: ValidAccountId }): Promise<U64>;

Returns how many Tokens are owned by account_id.

👓 nft_tokens_for_owner

nft_tokens_for_owner(args: { account_id: ValidAccountId, from_index: U64|null, limit: number|null }): Promise<Token[]>;

Returns all or paginated Tokens owned by account_id. Pagination is given by:

  • from_index the index to start fetching tokens.
  • limit indicates how many tokens will be at most returned.

👓 nft_token_uri

nft_token_uri(args: { token_id: TokenId }): Promise<string|null>;

Gets the URI for the given token_id. The uri combines the base_uri from the contract metadata and the gate_id from the token.


References

  • 🚀 Initialization method. Needs to be called right after deployment.
  • 👓 View only method, i.e., does not modify the contract state.
  • ✍️ Call method, i.e., does modify the contract state.
  • Ⓝ Payable method, i.e., call needs to have an attached NEAR deposit.

This documentation was generated with near-syn v0.3.0 https://github.com/epam/near-syn on 2021-05-03 08:06:39.461517 UTC