From a2f8b9cdc5b5164c6ce30c2e6a03c16439814b01 Mon Sep 17 00:00:00 2001 From: garikbesson Date: Mon, 15 Jan 2024 20:30:26 +0700 Subject: [PATCH 1/5] combined nft primitives pages into one --- docs/7.primitives/nft/using-nfts.md | 1637 +++++++++++++++++++++++++++ website/sidebars.json | 1 + 2 files changed, 1638 insertions(+) create mode 100644 docs/7.primitives/nft/using-nfts.md diff --git a/docs/7.primitives/nft/using-nfts.md b/docs/7.primitives/nft/using-nfts.md new file mode 100644 index 00000000000..d5be2c734ec --- /dev/null +++ b/docs/7.primitives/nft/using-nfts.md @@ -0,0 +1,1637 @@ +--- +id: using-nfts +title: Using NFTs +hide_table_of_contents: false +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import {CodeTabs, Language, Github} from "@site/src/components/codetabs" + +This section shows how to interact with an NFT smart contract. + +--- + +## Mint a NFT + + + + + + + ```js + const tokenData = Near.call( + "nft.primitives.near", + "nft_mint", + { + token_id: "1", + receiver_id: "bob.near", + token_metadata: { + title: "NFT Primitive Token", + description: "Awesome NFT Primitive Token", + media: "string", // URL to associated media, preferably to decentralized, content-addressed storage + } + }, + undefined, + 10000000000000000000000, // Depends on your NFT metadata + ); + ``` + + + + ```js + const tokenData = Near.call( + "x.paras.near", + "nft_mint", + { + token_series_id: "490641", + receiver_id: "bob.near", + }, + undefined, + 10000000000000000000000 // Depends on your NFT metadata + ); + ``` + + In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. + + + + ```js + const tokenData = Near.call( + "thomasettorreiv.mintbase1.near", + "nft_batch_mint", + { + num_to_mint: 1, + owner_id: "bob.near", + metadata: {}, + }, + undefined, + 10000000000000000000000 + ); + ``` + + In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. + + + + + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "nft.primitives.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_mint', + args: { + token_id: "1", + receiver_id: "bob.near", + token_metadata: { + title: "NFT Primitive Token", + description: "Awesome NFT Primitive Token", + media: "string", // URL to associated media, preferably to decentralized, content-addressed storage + } + }, + contractId: CONTRACT_ADDRESS, + deposit: 10000000000000000000000 + }); + ``` + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "x.paras.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_mint', + args: { + token_series_id: "490641", + receiver_id: "bob.near", + }, + contractId: CONTRACT_ADDRESS, + deposit: 10000000000000000000000 // Depends on your NFT metadata + }); + ``` + + In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. + + + By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_batch_mint', + args: { + num_to_mint: 1, + owner_id: "bob.near", + metadata: {}, + }, + contractId: CONTRACT_ADDRESS, + deposit: 10000000000000000000000 // Depends on your NFT metadata + }); + ``` + + In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. + + By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/mint) + + ```js + import { useState } from 'react'; + import { useWallet } from '@mintbase-js/react'; + import { execute, mint, MintArgs } from '@mintbase-js/sdk'; + + + export const MintComponent = ({ media, reference, contractAddress, owner }: MintArgs): JSX.Element => { + const { selector } = useWallet(); + + const handleMint = async (): Promise => { + const wallet = await selector.wallet(); + + await execute( + mint({ contractAddress, metadata: { media, reference }, ownerId: owner }) + ); + } + + return ( +
+ +
+ ); + }; + ``` +
+
+ All the examples are using a `Wallet` object, which comes from our basic template: + + +
+ + + + + ```bash + near call nft.primitives.near nft_mint '{"token_id": "1", "receiver_id": "bob.near", "token_metadata": {"title": "NFT Primitive Token", "description": "Awesome NFT Primitive Token", "media": "string"}}' --depositYocto 10000000000000000000000, --accountId bob.near + ``` + + + + + + ```bash + near call x.paras.near nft_mint '{"token_series_id": "490641", "receiver_id": "bob.near"}' --depositYocto 10000000000000000000000 --accountId bob.near + ``` + + In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. + + + + + ```bash + near call thomasettorreiv.mintbase1.near nft_batch_mint '{"num_to_mint": 1, "owner_id": "bob.near", "metadata": {}}' --accountId bob.near --depositYocto 10000000000000000000000 + ``` + + In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. + + + + +
+ + Minting in Paras + + + In case with Paras NFT contract before minting NFT token you may need to create token series from your contract account. You can do it via [Paras UI](https://paras.id/en) or use `near-cli`: + + ```bash + # Example of the command creating token series on Paras + near call x.paras.near nft_create_series '{"token_metadata": {"title": "NFT #1", "media": "bafybeibnpe5x6euhjtn5qrayfgeemxyru7ho3yhdyaifv7gsvdn46j6vzi", "reference": "bafybeif6cjn5bmdp7w5x2jms2xlz64qmp7crd5z77rl3iy3m54mlustdiu", "copies": 10}, "royalty": {"": 1000}, "price": null}' --accountId --depositYocto 6090000000000000000000 + ``` +
+ + ```rust + // Validator interface, for cross-contract calls + #[ext_contract(ext_nft_contract)] + trait ExternalNftContract { + fn nft_mint(&self, token_series_id: String, receiver_id: AccountId) -> Promise; + } + + // Implement the contract structure + #[near_bindgen] + impl Contract { + #[payable] + pub fn nft_mint(&mut self, token_series_id: String, receiver_id: AccountId) -> Promise { + let promise = ext_nft_contract::ext(self.nft_contract.clone()) + .with_static_gas(Gas(30*TGAS)) + .with_attached_deposit(env::attached_deposit()) + .nft_mint(token_series_id, receiver_id); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .with_static_gas(Gas(30*TGAS)) + .nft_mint_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn nft_mint_callback(&self, #[callback_result] call_result: Result) -> Option { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + return None; + } + + // Return the token data + let token_id: TokenId = call_result.unwrap(); + return Some(token_id); + } + } + ``` + + Values of gas and deposit might vary depending on which NFT contract you are calling. +
+
+ +--- + +## Buy a NFT + + + + + + + ```js + const tokenData = Near.call( + "x.paras.near", + "nft_buy", + { + token_series_id: "299102", + receiver_id: "bob.near", + }, + undefined, + 205740000000000000000000 // NFT price + storage cost + ); + ``` + + **Example response:** + + ```json + "299102:1" + ``` + + + + ```js + const tokenData = Near.call( + "simple.market.mintbase1.near", + "buy", + { + nft_contract_id: "rubennnnnnnn.mintbase1.near", + token_id: "38", + referrer_id: null, + }, + undefined, + 1000000000000000000000 // NFT price + storage cost (optional, depends on a contract) + ); + ``` + + **Example response:** + + ```json + { + "payout": { + "rub3n.near": "889200000000000000000", + "rubenm4rcus.near": "85800000000000000000" + } + } + ``` + + + + + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "x.paras.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_buy', + args: { + token_series_id: "299102", + receiver_id: "bob.near", + }, + contractId: CONTRACT_ADDRESS, + deposit: 205740000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost + }); + ``` + + **Example response:** + + ```json + "299102:1" + ``` + + + By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'buy', + args: { + nft_contract_id: "rubennnnnnnn.mintbase1.near", + token_id: "38" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1000000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost (optional) + }); + ``` + + **Example response:** + + ```json + { + "payout": { + "rub3n.near": "889200000000000000000", + "rubenm4rcus.near": "85800000000000000000" + } + } + ``` + + By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/buy) + + ```js + import { useState } from 'react'; + import { useWallet } from '@mintbase-js/react'; + import { execute, burn, BuyArgs } from '@mintbase-js/sdk'; + + export const BuyComponent = ({ contractAddress, price, tokenId, affiliateAccount, marketId }: BuyArgs): JSX.Element => { + const { selector } = useWallet(); + + const handleBuy = async (): Promise => { + const wallet = await selector.wallet(); + + const buyArgs = { + contractAddress, + tokenId, + affiliateAccount, + marketId, + price, + } + + await execute( + { wallet }, + buy(buyArgs) + ); + + } + + return ( +
+ +
+ ); + }; + ``` +
+
+ All the examples are using a `Wallet` object, which comes from our basic template: + + +
+ + + + + ```bash + near call x.paras.near buy '{"token_series_id": "299102", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.20574 + ``` + + **Example response:** + + ```json + "299102:1" + ``` + + + + ```bash + near call simple.market.mintbase1.near buy '{"nft_contract_id": "rubennnnnnnn.mintbase1.near", "token_id": "38"}' --accountId bob.near --deposit 0.001 + ``` + + **Example response:** + + ```json + { + "payout": { + "rub3n.near": "889200000000000000000", + "rubenm4rcus.near": "85800000000000000000" + } + } + ``` + + + + + + This is an example on how you can make your smart contract buy a NFT on some marketplace (Paras this case). + + Please note that in this example the contract will be the owner of the NFT, however, some marketplaces allow you to buy NFT for somebody else. + + ```rust + const NFT_MARKETPLACE_CONTRACT: &str = "paras-marketplace-v2.testnet"; + + // Define the contract structure + #[near_bindgen] + #[derive(BorshDeserialize, BorshSerialize)] + pub struct Contract { + nft_marketplace_contract: AccountId + } + + impl Default for Contract { + // The default trait with which to initialize the contract + fn default() -> Self { + Self { + nft_marketplace_contract: NFT_MARKETPLACE_CONTRACT.parse().unwrap() + } + } + } + + // Validator interface, for cross-contract calls + #[ext_contract(ext_nft_contract)] + trait ExternalNftContract { + fn buy(&self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise; + } + + // Implement the contract structure + #[near_bindgen] + impl Contract { + #[payable] + pub fn buy(&mut self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise { + let promise = ext_nft_contract::ext(self.nft_marketplace_contract.clone()) + .with_static_gas(Gas(30*TGAS)) + .with_attached_deposit(env::attached_deposit()) + .buy(nft_contract_id, token_id, ft_token_id, price); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .with_static_gas(Gas(30*TGAS)) + .buy_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn buy_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + } + } + } + ``` + +
+ +--- + +## Query NFT data + + + + + + + ```js + const tokenData = Near.view("nft.primitives.near", "nft_token", { + token_id: "1", + }); + ``` + + **Example response:** + + ```json + { + "token_id": "1", + "owner_id": "bob.near", + "metadata": { + "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" + "description": "string", // free-form description + "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage + "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + "copies": 1, // number of copies of this set of metadata in existence when token was minted. + "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds + "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds + "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds + "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds + "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. + "reference": "string", // URL to an off-chain JSON file with more info. + "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + } + } + ``` + + + By calling a Paras smart contract method + + ```js + const tokenData = Near.view("x.paras.near", "nft_token", { + token_id: "84686:1154", + }); + ``` + + **Example response:** + + ```json + { + "token_id": "84686:1154", + "owner_id": "bob.near", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": null, + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": "1642053411068358156", + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null + }, + "approved_account_ids": {} + } + ``` + + By calling a Paras API method + + ```js + const tokenData = fetch("https://api-v2-mainnet.paras.id/token?token_id=84686:1154"); + ``` + + **Example response:** + + ```json + { + "status": 1, + "data": { + "results": [ + { + "_id": "61dfbf27284abc1cc0b87c9d", + "contract_id": "x.paras.near", + "token_id": "84686:1154", + "owner_id": "bob.near", + "token_series_id": "84686", + "edition_id": "1154", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": "Holding this silver coin in your wallet will bring you health and happiness \uD83D\uDE0A", + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null, + "collection": "Tokenfox Collection Cards", + "collection_id": "tokenfox-collection-cards-by-tokenfoxnear", + "creator_id": "tokenfox.near", + "blurhash": "U7F~gc00_3D%00~q4n%M_39F-;RjM{xuWBRj", + "score": 0, + "mime_type": "image/png" + }, + "royalty": { + "tokenfox.near": 1000 + }, + "price": null, + "approval_id": null, + "ft_token_id": null, + "has_price": null, + "is_creator": true, + "total_likes": 8, + "likes": null, + "categories": [], + "view": 4 + } + ], + "count": 1, + "skip": 0, + "limit": 10 + } + } + ``` + + See the [Paras API documentation](https://parashq.github.io/) for the full list of methods. + + When you call Paras smart contract method it returns data that are stored in the Paras NFT smart contract. It means a response contains only data about NFTs which were minted via Paras NFT contract. + + When you call Paras API methods it returns data from other NFT contracts as well, due to the work of the indexer. It means you might want to pass more parameters like `contract_id` or `owner_id` to make the response more accurate. + + + By calling a Mintbase smart contract method + + ```js + const tokenData = Near.view("anthropocene.mintbase1.near", "nft_token", { + token_id: "17960", + }); + ``` + + **Example response:** + + ```json + { + "token_id": "17960", + "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", + "approved_account_ids": {}, + "metadata": { + "title": null, + "description": null, + "media": null, + "media_hash": null, + "copies": 1, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", + "reference_hash": null + }, + "royalty": { + "split_between": { + "seventhage.near": { + "numerator": 10000 + } + }, + "percentage": { + "numerator": 100 + } + }, + "split_owners": null, + "minter": "anthropocene.seventhage.near", + "loan": null, + "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, + "origin_key": null + } + ``` + + When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. + + By calling a Mintbase GraphQL API method + + ```js + const tokenData = fetch("https://graph.mintbase.xyz", { + method: "POST", + headers: { + "mb-api-key": "anon", + "Content-Type": "application/json", + "x-hasura-role": "anonymous", + }, + body: JSON.stringify({ + query: ` + query getToken{ + tokens: nft_tokens( + where: { + token_id: { _eq: "84686:1154" } + } + ) { + tokenId: token_id + ownerId: owner + contractId: nft_contract_id + reference + issuedAt: issued_at + copies + metadataId: metadata_id + } + } + `, + }), + }); + ``` + + **Example response:** + + ```json + { + "ok": true, + "status": 200, + "contentType": "application/json", + "body": { + "data": { + "tokens": [ + { + "tokenId": "84686:1154", + "ownerId": "bob.near", + "contractId": "x.paras.near", + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "issuedAt": "2022-01-13T05:56:51.068358", + "copies": 4063, + "metadataId": "x.paras.near:5210047642790498956c9669d6a37b98" + } + ] + } + } + } + ``` + + In the future, users may be required to register using an api key. For now, simply passing the valueanon for `mb-api-key` will work. + + + + + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "nft.primitives.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + const response = await wallet.viewMethod({ + method: 'nft_token', + args: { + token_id: "1" + } + }); + ``` + + **Example response:** + + ```json + { + "token_id": "1", + "owner_id": "bob.near", + "metadata": { + "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" + "description": "string", // free-form description + "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage + "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + "copies": 1, // number of copies of this set of metadata in existence when token was minted. + "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds + "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds + "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds + "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds + "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. + "reference": "string", // URL to an off-chain JSON file with more info. + "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + } + } + ``` + + + By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "x.paras.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + const response = await wallet.viewMethod({ + method: 'nft_token', + args: { + token_id: "84686:1154" + } + }); + ``` + + **Example response:** + + ```json + { + "token_id": "84686:1154", + "owner_id": "bob.near", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": null, + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": "1642053411068358156", + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null + }, + "approved_account_ids": {} + } + ``` + + By calling a Paras API method + + ```js + const tokenData = fetch("https://api-v2-mainnet.paras.id/token?token_id=84686:1154"); + ``` + + **Example response:** + + ```json + { + "status": 1, + "data": { + "results": [ + { + "_id": "61dfbf27284abc1cc0b87c9d", + "contract_id": "x.paras.near", + "token_id": "84686:1154", + "owner_id": "bob.near", + "token_series_id": "84686", + "edition_id": "1154", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": "Holding this silver coin in your wallet will bring you health and happiness \uD83D\uDE0A", + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null, + "collection": "Tokenfox Collection Cards", + "collection_id": "tokenfox-collection-cards-by-tokenfoxnear", + "creator_id": "tokenfox.near", + "blurhash": "U7F~gc00_3D%00~q4n%M_39F-;RjM{xuWBRj", + "score": 0, + "mime_type": "image/png" + }, + "royalty": { + "tokenfox.near": 1000 + }, + "price": null, + "approval_id": null, + "ft_token_id": null, + "has_price": null, + "is_creator": true, + "total_likes": 8, + "likes": null, + "categories": [], + "view": 4 + } + ], + "count": 1, + "skip": 0, + "limit": 10 + } + } + ``` + + See the [Paras API documentation](https://parashq.github.io/) for the full list of methods. + + When you call Paras smart contract method it returns data that are stored in the Paras NFT smart contract. It means a response contains only data about NFTs which were minted via Paras NFT contract. + + When you call Paras API methods it returns data from other NFT contracts as well, due to the work of the indexer. It means you might want to pass more parameters like `contract_id` or `owner_id` to make the response more accurate. + + + By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "anthropocene.mintbase1.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + const response = await wallet.viewMethod({ + method: 'nft_token', + args: { + token_id: "17960" + } + }); + ``` + + **Example response:** + + ```json + { + "token_id": "17960", + "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", + "approved_account_ids": {}, + "metadata": { + "title": null, + "description": null, + "media": null, + "media_hash": null, + "copies": 1, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", + "reference_hash": null + }, + "royalty": { + "split_between": { + "seventhage.near": { + "numerator": 10000 + } + }, + "percentage": { + "numerator": 100 + } + }, + "split_owners": null, + "minter": "anthropocene.seventhage.near", + "loan": null, + "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, + "origin_key": null + } + ``` + + When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. + + By calling a Mintbase GraphQL API method + + ```js + const tokenData = fetch("https://graph.mintbase.xyz", { + method: "POST", + headers: { + "mb-api-key": "anon", + "Content-Type": "application/json", + "x-hasura-role": "anonymous", + }, + body: JSON.stringify({ + query: ` + query getToken{ + tokens: nft_tokens( + where: { + token_id: { _eq: "84686:1154" } + } + ) { + tokenId: token_id + ownerId: owner + contractId: nft_contract_id + reference + issuedAt: issued_at + copies + metadataId: metadata_id + } + } + `, + }), + }); + ``` + + **Example response:** + + ```json + { + "ok": true, + "status": 200, + "contentType": "application/json", + "body": { + "data": { + "tokens": [ + { + "tokenId": "84686:1154", + "ownerId": "bob.near", + "contractId": "x.paras.near", + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "issuedAt": "2022-01-13T05:56:51.068358", + "copies": 4063, + "metadataId": "x.paras.near:5210047642790498956c9669d6a37b98" + } + ] + } + } + } + ``` + + In the future, users may be required to register using an api key. For now, simply passing the valueanon for `mb-api-key` will work. + + By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/data/api/tokenbyid) + + ```js + import { tokenById } from '@mintbase-js/data' + + const { data, error } = await tokenById('1','rub3n.testnet'); + + if (error) { + console.log(error); + } + + console.log(data.tokenData[0]) // => token metadata + ``` + + + + All the examples are using a `Wallet` object, which comes from our basic template: + + + + + + + + ```bash + near view nft.primitives.near nft_token '{"token_id": "1"}' + ``` + + **Example response:** + + ```json + { + "token_id": "1", + "owner_id": "bob.near", + "metadata": { + "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" + "description": "string", // free-form description + "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage + "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + "copies": 1, // number of copies of this set of metadata in existence when token was minted. + "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds + "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds + "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds + "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds + "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. + "reference": "string", // URL to an off-chain JSON file with more info. + "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + } + } + ``` + + + + ```bash + near view x.paras.near nft_token '{"token_id": "84686:1154"}' + ``` + + **Example response:** + + ```json + { + "token_id": "84686:1154", + "owner_id": "bob.near", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": null, + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": "1642053411068358156", + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null + }, + "approved_account_ids": {} + } + ``` + + + + ```bash + near view anthropocene.mintbase1.near nft_token '{"token_id": "17960"}' + ``` + + **Example response:** + + ```json + { + "token_id": "17960", + "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", + "approved_account_ids": {}, + "metadata": { + "title": null, + "description": null, + "media": null, + "media_hash": null, + "copies": 1, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", + "reference_hash": null + }, + "royalty": { + "split_between": { + "seventhage.near": { + "numerator": 10000 + } + }, + "percentage": { + "numerator": 100 + } + }, + "split_owners": null, + "minter": "anthropocene.seventhage.near", + "loan": null, + "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, + "origin_key": null + } + ``` + + When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. + + + + + + ```rust + // Validator interface, for cross-contract calls + #[ext_contract(ext_nft_contract)] + trait ExternalNftContract { + fn nft_token(&self, token_id: TokenId) -> Promise; + } + + // Implement the contract structure + #[near_bindgen] + impl Contract { + pub fn nft_token(&self, token_id: TokenId) -> Promise { + let promise = ext_nft_contract::ext(self.nft_contract.clone()) + .nft_token(token_id); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .nft_token_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn nft_token_callback(&self, #[callback_result] call_result: Result) -> Option { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + return None; + } + + // Return the token data + let token_data: Token = call_result.unwrap(); + return Some(token_data); + } + } + ``` + + + +--- + +## Transfer a NFT + + + + + + + ```js + const tokenData = Near.call( + "nft.primitives.near", + "nft_transfer", + { + token_id: "1", + receiver_id: "bob.near" + }, + undefined, + 1, + ); + ``` + + + + ```js + const tokenData = Near.call( + "x.paras.near", + "nft_transfer", + { + token_id: "490641", + receiver_id: "bob.near" + }, + undefined, + 1 + ); + ``` + + + + ```js + const tokenData = Near.call( + "thomasettorreiv.mintbase1.near", + "nft_transfer", + { + token_id: "490641", + receiver_id: "bob.near" + }, + undefined, + 1 + ); + ``` + + + + + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "nft.primitives.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_transfer', + args: { + token_id: "1", + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1 + }); + ``` + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "x.paras.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_transfer', + args: { + token_id: "490641", + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1 + }); + ``` + + + By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'nft_transfer', + args: { + token_id: "490641", + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1 + }); + ``` + + By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/transfer) + + ```js + import { useState } from 'react'; + import { useWallet } from '@mintbase-js/react'; + import { execute, transfer, TransferArgs } from '@mintbase-js/sdk'; + + const TransferComponent = ({ tokenId, contractAddress }: TransferArgs): JSX.Element => { + const { selector, activeAccountId } = useWallet(); + + const handleTransfer = async (): Promise => { + const wallet = await selector.wallet(); + + const transferArgs: TransferArgs = { + contractAddress: contractAddress, + transfers: [{ + receiverId: 'mb_carol.testnet', + tokenId: token.tokenId, + }], + } + + await execute( + { wallet }, + transfer(transferArgs), + ); + }; + + return ( +
+ +
+ ); + } + ``` +
+
+ All the examples are using a `Wallet` object, which comes from our basic template: + + +
+ + + + + ```bash + near call nft.primitives.near nft_transfer '{"token_id": "1", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 + ``` + + + ```bash + near call x.paras.near nft_transfer '{"token_id": "490641", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 + ``` + + + ```bash + near call thomasettorreiv.mintbase1.near nft_transfer '{"token_id": "490641" "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 + ``` + + + + + Please notice that a contract can only transfer an NFT that they own, or an NFT that they were approved to transfer. + + ```rust + const YOCTO_NEAR: u128 = 1; + + #[ext_contract(ext_nft_contract)] + trait ExternalNftContract { + fn nft_transfer(&self, receiver_id: AccountId, token_id: TokenId) -> Promise; + } + + impl Contract { + #[payable] + pub fn nft_transfer(&mut self, receiver_id: AccountId, token_id: TokenId) -> Promise { + let promise = ext_nft_contract::ext(self.nft_contract.clone()) + .with_attached_deposit(YOCTO_NEAR) + .nft_transfer(receiver_id, token_id); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .nft_transfer_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn nft_transfer_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + } + } + } + ``` + + +
+ +--- + +## List a NFT for sale + +Basic NFT contracts following [the NEP-171 and NEP-177 standards](https://nomicon.io/Standards/Tokens/NonFungibleToken) do not implement marketplace functionality. + +For this purpose, there are ecosystem apps such as [Paras](https://paras.id/) or [Mintbase](https://www.mintbase.xyz/), that use dedicated marketplace contracts. + +In order to put a NFT for a sale on a marketplace you need to do two actions: + +1. Cover data storage costs in the marketplace contract. +2. Approve the marketplace to sell the NFT in your NFT contract. + + + + + + + ```js + Near.call( + "marketplace.paras.near", + "storage_deposit", + { + receiver_id: "bob.near" + }, + undefined, + 9390000000000000000 + ); + + Near.call( + "nft.primitives.near", + "nft_approve", + { + token_id: "1e95238d266e5497d735eb30", + account_id: "marketplace.paras.near", + msg: { + price: "200000000000000000000000", + market_type: "sale", + ft_token_id: "near" + } + } + ); + ``` + + The method `nft_approve` will call `nft_on_approve` in `marketplace.paras.near`. + + + + ```js + Near.call( + "simple.market.mintbase1.near", + "deposit_storage", + { + autotransfer: true + }, + undefined, + 9390000000000000000 + ); + + Near.call( + "nft.primitives.near", + "nft_approve", + { + token_id: "3c46b76cbd48e65f2fc88473", + account_id: "simple.market.mintbase1.near", + msg: { + price: "200000000000000000000000" + } + } + ); + ``` + + The method `nft_approve` will call `nft_on_approve` in `simple.market.mintbase1.near`. + + + + + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "marketplace.paras.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'storage_deposit', + args: { + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + gas: 300000000000000, // attached GAS (optional) + deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) + }); + + await wallet.callMethod({ + method: 'nft_approve', + args: { + token_id: "1e95238d266e5497d735eb30", + account_id: "marketplace.paras.near", + msg: { + price: "200000000000000000000000", + market_type: "sale", + ft_token_id: "near" + } + }, + contractId: "nft.primitives.near" + }); + ``` + + Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. + + + + ```js + import { Wallet } from './near-wallet'; + + const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; + const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + + await wallet.callMethod({ + method: 'deposit_storage', + args: { + autotransfer: true + }, + contractId: CONTRACT_ADDRESS, + gas: 300000000000000, // attached GAS (optional) + deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) + }); + + await wallet.callMethod({ + method: 'nft_approve', + args: { + args: { + token_id: "3c46b76cbd48e65f2fc88473", + account_id: "simple.market.mintbase1.near", + msg: { + price: "200000000000000000000000" + } + }, + }, + contractId: "nft.primitives.near" + }); + ``` + + Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. + + By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/list) + + ```js + import { useState } from 'react'; + import { useWallet } from '@mintbase-js/react'; + import { execute, list, ListArgs } from '@mintbase-js/sdk'; + + export const ListComponent = ({ contractAddress, marketAddress , tokenId, price }: ListArgs): JSX.Element => { + + const { selector } = useWallet(); + + const handleList = async (): Promise => { + const wallet = await selector.wallet(); + + await execute( + { wallet }, + list({ + contractAddress: nftContractId, + marketAddress: marketId, + tokenId: tokenId, + price: price + }) + ) + } + + return ( +
+ +
+ ); + }; + ``` +
+
+ All the examples are using a `Wallet` object, which comes from our basic template: + + +
+ + + + + ```bash + near call marketplace.paras.near storage_deposit '{"receiver_id": "bob.near"}' --accountId bob.near --deposit 0.00939 + + near call nft.primitives.near nft_approve '{"token_id": "1e95238d266e5497d735eb30", "account_id": "marketplace.paras.near", "msg": {"price": "200000000000000000000000", "market_type": "sale", "ft_token_id": "near"}}' --accountId bob.near + ``` + + Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. + + + + ```bash + near call simple.market.mintbase1.near deposit_storage '{"autotransfer": "true"}' --accountId bob.near --deposit 0.00939 + + near call nft.primitives.near nft_approve '{"token_id": "3c46b76cbd48e65f2fc88473", "account_id": "simple.market.mintbase1.near", "msg": {"price": "200000000000000000000000"}}' --accountId bob.near + ``` + + Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. + + + +
diff --git a/website/sidebars.json b/website/sidebars.json index 409fef018c1..42452d45ce3 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -366,6 +366,7 @@ "value": " Non Fungible Tokens (NFT) " }, "primitives/nft/introduction", + "primitives/nft/using-nfts", { "Using NFTs": [ "primitives/nft/interacting/bos", From 2d3ff68d9f36f095e80ae24164cf50cb432ab389 Mon Sep 17 00:00:00 2001 From: garikbesson Date: Thu, 18 Jan 2024 17:08:10 +0700 Subject: [PATCH 2/5] added groupId to tabs on NFT primitive page --- docs/7.primitives/nft/using-nfts.md | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/7.primitives/nft/using-nfts.md b/docs/7.primitives/nft/using-nfts.md index d5be2c734ec..3c2848676e7 100644 --- a/docs/7.primitives/nft/using-nfts.md +++ b/docs/7.primitives/nft/using-nfts.md @@ -14,9 +14,9 @@ This section shows how to interact with an NFT smart contract. ## Mint a NFT - + - + ```js @@ -75,7 +75,7 @@ This section shows how to interact with an NFT smart contract. - + ```js @@ -181,7 +181,7 @@ This section shows how to interact with an NFT smart contract. start="20" end="27" /> - + ```bash @@ -270,9 +270,9 @@ This section shows how to interact with an NFT smart contract. ## Buy a NFT - + - + ```js @@ -324,7 +324,7 @@ This section shows how to interact with an NFT smart contract. - + ```js @@ -427,7 +427,7 @@ This section shows how to interact with an NFT smart contract. start="20" end="27" /> - + ```bash @@ -523,9 +523,9 @@ This section shows how to interact with an NFT smart contract. ## Query NFT data - + - + ```js @@ -769,7 +769,7 @@ This section shows how to interact with an NFT smart contract. - + ```js @@ -1057,7 +1057,7 @@ This section shows how to interact with an NFT smart contract. start="20" end="27" /> - + ```bash @@ -1209,9 +1209,9 @@ This section shows how to interact with an NFT smart contract. ## Transfer a NFT - + - + ```js @@ -1260,7 +1260,7 @@ This section shows how to interact with an NFT smart contract. - + ```js @@ -1364,7 +1364,7 @@ This section shows how to interact with an NFT smart contract. start="20" end="27" /> - + ```bash @@ -1433,9 +1433,9 @@ In order to put a NFT for a sale on a marketplace you need to do two actions: 1. Cover data storage costs in the marketplace contract. 2. Approve the marketplace to sell the NFT in your NFT contract. - + - + ```js @@ -1497,7 +1497,7 @@ In order to put a NFT for a sale on a marketplace you need to do two actions: - + ```js @@ -1611,7 +1611,7 @@ In order to put a NFT for a sale on a marketplace you need to do two actions: start="20" end="27" /> - + ```bash From 056e4a50dac14d6e6c2f0cea9f2891cd537a1867 Mon Sep 17 00:00:00 2001 From: garikbesson Date: Tue, 23 Jan 2024 10:19:47 +0300 Subject: [PATCH 3/5] split the nft primitive page onto components (md pages) --- docs/7.primitives/nft/interacting/bos/buy.md | 59 + .../nft/interacting/bos/list-for-sale.md | 66 + docs/7.primitives/nft/interacting/bos/mint.md | 70 + .../nft/interacting/{bos.md => bos/query.md} | 296 +-- .../nft/interacting/bos/transfer.md | 55 + docs/7.primitives/nft/interacting/near-cli.md | 291 --- .../nft/interacting/near-cli/buy.md | 39 + .../nft/interacting/near-cli/list-for-sale.md | 28 + .../nft/interacting/near-cli/mint.md | 37 + .../nft/interacting/near-cli/query.md | 121 ++ .../nft/interacting/near-cli/transfer.md | 28 + .../nft/interacting/smart-contract.md | 272 --- .../nft/interacting/smart-contract/buy.md | 65 + .../nft/interacting/smart-contract/mint.md | 64 + .../nft/interacting/smart-contract/query.md | 42 + .../interacting/smart-contract/transfer.md | 42 + docs/7.primitives/nft/interacting/web-app.md | 778 -------- .../nft/interacting/web-app/buy.md | 105 ++ .../nft/interacting/web-app/list-for-sale.md | 119 ++ .../nft/interacting/web-app/mint.md | 120 ++ .../nft/interacting/web-app/query.md | 306 ++++ .../nft/interacting/web-app/transfer.md | 113 ++ docs/7.primitives/nft/using-nfts.md | 1588 +---------------- website/sidebars.js | 8 - 24 files changed, 1524 insertions(+), 3188 deletions(-) create mode 100644 docs/7.primitives/nft/interacting/bos/buy.md create mode 100644 docs/7.primitives/nft/interacting/bos/list-for-sale.md create mode 100644 docs/7.primitives/nft/interacting/bos/mint.md rename docs/7.primitives/nft/interacting/{bos.md => bos/query.md} (58%) create mode 100644 docs/7.primitives/nft/interacting/bos/transfer.md delete mode 100644 docs/7.primitives/nft/interacting/near-cli.md create mode 100644 docs/7.primitives/nft/interacting/near-cli/buy.md create mode 100644 docs/7.primitives/nft/interacting/near-cli/list-for-sale.md create mode 100644 docs/7.primitives/nft/interacting/near-cli/mint.md create mode 100644 docs/7.primitives/nft/interacting/near-cli/query.md create mode 100644 docs/7.primitives/nft/interacting/near-cli/transfer.md delete mode 100644 docs/7.primitives/nft/interacting/smart-contract.md create mode 100644 docs/7.primitives/nft/interacting/smart-contract/buy.md create mode 100644 docs/7.primitives/nft/interacting/smart-contract/mint.md create mode 100644 docs/7.primitives/nft/interacting/smart-contract/query.md create mode 100644 docs/7.primitives/nft/interacting/smart-contract/transfer.md delete mode 100644 docs/7.primitives/nft/interacting/web-app.md create mode 100644 docs/7.primitives/nft/interacting/web-app/buy.md create mode 100644 docs/7.primitives/nft/interacting/web-app/list-for-sale.md create mode 100644 docs/7.primitives/nft/interacting/web-app/mint.md create mode 100644 docs/7.primitives/nft/interacting/web-app/query.md create mode 100644 docs/7.primitives/nft/interacting/web-app/transfer.md diff --git a/docs/7.primitives/nft/interacting/bos/buy.md b/docs/7.primitives/nft/interacting/bos/buy.md new file mode 100644 index 00000000000..a35f9122efb --- /dev/null +++ b/docs/7.primitives/nft/interacting/bos/buy.md @@ -0,0 +1,59 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```js +const tokenData = Near.call( + "x.paras.near", + "nft_buy", + { + token_series_id: "299102", + receiver_id: "bob.near", + }, + undefined, + 205740000000000000000000 // NFT price + storage cost +); +``` + +**Example response:** + +```json +"299102:1" +``` + + + + + + +```js +const tokenData = Near.call( + "simple.market.mintbase1.near", + "buy", + { + nft_contract_id: "rubennnnnnnn.mintbase1.near", + token_id: "38", + referrer_id: null, + }, + undefined, + 1000000000000000000000 // NFT price + storage cost (optional, depends on a contract) +); +``` + +**Example response:** + +```json +{ + "payout": { + "rub3n.near": "889200000000000000000", + "rubenm4rcus.near": "85800000000000000000" + } +} +``` + + + + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/bos/list-for-sale.md b/docs/7.primitives/nft/interacting/bos/list-for-sale.md new file mode 100644 index 00000000000..3c3541b38be --- /dev/null +++ b/docs/7.primitives/nft/interacting/bos/list-for-sale.md @@ -0,0 +1,66 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```js +Near.call( + "marketplace.paras.near", + "storage_deposit", + { + receiver_id: "bob.near" + }, + undefined, + 9390000000000000000 +); + +Near.call( + "nft.primitives.near", + "nft_approve", + { + token_id: "1e95238d266e5497d735eb30", + account_id: "marketplace.paras.near", + msg: { + price: "200000000000000000000000", + market_type: "sale", + ft_token_id: "near" + } + } +); +``` + +The method `nft_approve` will call `nft_on_approve` in `marketplace.paras.near`. + + + + + +```js +Near.call( + "simple.market.mintbase1.near", + "deposit_storage", + { + autotransfer: true + }, + undefined, + 9390000000000000000 +); + +Near.call( + "nft.primitives.near", + "nft_approve", + { + token_id: "3c46b76cbd48e65f2fc88473", + account_id: "simple.market.mintbase1.near", + msg: { + price: "200000000000000000000000" + } + } +); +``` + +The method `nft_approve` will call `nft_on_approve` in `simple.market.mintbase1.near`. + + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/bos/mint.md b/docs/7.primitives/nft/interacting/bos/mint.md new file mode 100644 index 00000000000..a07b2b85af7 --- /dev/null +++ b/docs/7.primitives/nft/interacting/bos/mint.md @@ -0,0 +1,70 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```js +const tokenData = Near.call( + "nft.primitives.near", + "nft_mint", + { + token_id: "1", + receiver_id: "bob.near", + token_metadata: { + title: "NFT Primitive Token", + description: "Awesome NFT Primitive Token", + media: "string", // URL to associated media, preferably to decentralized, content-addressed storage + } + }, + undefined, + 10000000000000000000000, // Depends on your NFT metadata +); +``` + + + + + +```js +const tokenData = Near.call( + "x.paras.near", + "nft_mint", + { + token_series_id: "490641", + receiver_id: "bob.near", + }, + undefined, + 10000000000000000000000 // Depends on your NFT metadata +); +``` + +:::note +In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. +::: + + + + + +```js +const tokenData = Near.call( + "thomasettorreiv.mintbase1.near", + "nft_batch_mint", + { + num_to_mint: 1, + owner_id: "bob.near", + metadata: {}, + }, + undefined, + 10000000000000000000000 +); +``` + +:::note +In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. +::: + + + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/bos.md b/docs/7.primitives/nft/interacting/bos/query.md similarity index 58% rename from docs/7.primitives/nft/interacting/bos.md rename to docs/7.primitives/nft/interacting/bos/query.md index e9e058c67b8..6e866efea0f 100644 --- a/docs/7.primitives/nft/interacting/bos.md +++ b/docs/7.primitives/nft/interacting/bos/query.md @@ -1,158 +1,7 @@ ---- -id: bos -title: NEAR Component -hide_table_of_contents: false ---- - import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -This section shows how to interact with an NFT smart contract directly from a [NEAR Component](../../../bos/components.md) - ---- - -## Mint a NFT - -This snippet will enable your users to mint NFTs in one of the NFT solutions. - - - - -```js -const tokenData = Near.call( - "nft.primitives.near", - "nft_mint", - { - token_id: "1", - receiver_id: "bob.near", - token_metadata: { - title: "NFT Primitive Token", - description: "Awesome NFT Primitive Token", - media: "string", // URL to associated media, preferably to decentralized, content-addressed storage - } - }, - undefined, - 10000000000000000000000, // Depends on your NFT metadata -); -``` - - - - - -```js -const tokenData = Near.call( - "x.paras.near", - "nft_mint", - { - token_series_id: "490641", - receiver_id: "bob.near", - }, - undefined, - 10000000000000000000000 // Depends on your NFT metadata -); -``` - -:::note -In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. -::: - - - - - -```js -const tokenData = Near.call( - "thomasettorreiv.mintbase1.near", - "nft_batch_mint", - { - num_to_mint: 1, - owner_id: "bob.near", - metadata: {}, - }, - undefined, - 10000000000000000000000 -); -``` - -:::note -In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. -::: - - - - - ---- - -## Buy a NFT - -This snippet will enable your users to buy NFTs in one of the NFT solutions. - - - - -```js -const tokenData = Near.call( - "x.paras.near", - "nft_buy", - { - token_series_id: "299102", - receiver_id: "bob.near", - }, - undefined, - 205740000000000000000000 // NFT price + storage cost -); -``` - -**Example response:** - -```json -"299102:1" -``` - - - - - - -```js -const tokenData = Near.call( - "simple.market.mintbase1.near", - "buy", - { - nft_contract_id: "rubennnnnnnn.mintbase1.near", - token_id: "38", - referrer_id: null, - }, - undefined, - 1000000000000000000000 // NFT price + storage cost (optional, depends on a contract) -); -``` - -**Example response:** - -```json -{ - "payout": { - "rub3n.near": "889200000000000000000", - "rubenm4rcus.near": "85800000000000000000" - } -} -``` - - - - - - ---- - -## Query NFT data - -This snippet will enable your users to query NFT data in one of the NFT solutions. - - + ```js @@ -413,145 +262,4 @@ In the future, users may be required to register using an api key. For now, simp ::: - - - ---- - -## Transfer a NFT - -This snippet will enable your users to transfer NFTs in one of the NFT solutions. - - - - -```js -const tokenData = Near.call( - "nft.primitives.near", - "nft_transfer", - { - token_id: "1", - receiver_id: "bob.near" - }, - undefined, - 1, -); -``` - - - - - -```js -const tokenData = Near.call( - "x.paras.near", - "nft_transfer", - { - token_id: "490641", - receiver_id: "bob.near" - }, - undefined, - 1 -); -``` - - - - - -```js -const tokenData = Near.call( - "thomasettorreiv.mintbase1.near", - "nft_transfer", - { - token_id: "490641", - receiver_id: "bob.near" - }, - undefined, - 1 -); -``` - - - - - ---- - -## List a NFT for sale - -Basic NFT contracts following [the NEP-171 and NEP-177 standards](https://nomicon.io/Standards/Tokens/NonFungibleToken) do not implement marketplace functionality. - -For this purpose, there are ecosystem apps such as [Paras](https://paras.id/) or [Mintbase](https://www.mintbase.xyz/), that use dedicated marketplace contracts. - -In order to put a NFT for a sale on a marketplace you need to do two actions: - -1. Cover data storage costs in the marketplace contract. -2. Approve the marketplace to sell the NFT in your NFT contract. - - - - - - -```js -Near.call( - "marketplace.paras.near", - "storage_deposit", - { - receiver_id: "bob.near" - }, - undefined, - 9390000000000000000 -); - -Near.call( - "nft.primitives.near", - "nft_approve", - { - token_id: "1e95238d266e5497d735eb30", - account_id: "marketplace.paras.near", - msg: { - price: "200000000000000000000000", - market_type: "sale", - ft_token_id: "near" - } - } -); -``` - -The method `nft_approve` will call `nft_on_approve` in `marketplace.paras.near`. - - - - - -```js -Near.call( - "simple.market.mintbase1.near", - "deposit_storage", - { - autotransfer: true - }, - undefined, - 9390000000000000000 -); - -Near.call( - "nft.primitives.near", - "nft_approve", - { - token_id: "3c46b76cbd48e65f2fc88473", - account_id: "simple.market.mintbase1.near", - msg: { - price: "200000000000000000000000" - } - } -); -``` - -The method `nft_approve` will call `nft_on_approve` in `simple.market.mintbase1.near`. - - - - + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/bos/transfer.md b/docs/7.primitives/nft/interacting/bos/transfer.md new file mode 100644 index 00000000000..6a00df37d7a --- /dev/null +++ b/docs/7.primitives/nft/interacting/bos/transfer.md @@ -0,0 +1,55 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```js +const tokenData = Near.call( + "nft.primitives.near", + "nft_transfer", + { + token_id: "1", + receiver_id: "bob.near" + }, + undefined, + 1, +); +``` + + + + + +```js +const tokenData = Near.call( + "x.paras.near", + "nft_transfer", + { + token_id: "490641", + receiver_id: "bob.near" + }, + undefined, + 1 +); +``` + + + + + +```js +const tokenData = Near.call( + "thomasettorreiv.mintbase1.near", + "nft_transfer", + { + token_id: "490641", + receiver_id: "bob.near" + }, + undefined, + 1 +); +``` + + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/near-cli.md b/docs/7.primitives/nft/interacting/near-cli.md deleted file mode 100644 index 09bb203e2a9..00000000000 --- a/docs/7.primitives/nft/interacting/near-cli.md +++ /dev/null @@ -1,291 +0,0 @@ ---- -id: near-cli -title: NEAR CLI -hide_table_of_contents: false ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -This section shows how to interact with an NFT contract from your shell using [`near-cli`](../../../4.tools/cli.md). - ---- - -## Mint a NFT - - - - -```bash -near call nft.primitives.near nft_mint '{"token_id": "1", "receiver_id": "bob.near", "token_metadata": {"title": "NFT Primitive Token", "description": "Awesome NFT Primitive Token", "media": "string"}}' --depositYocto 10000000000000000000000, --accountId bob.near -``` - - - - - -```bash -near call x.paras.near nft_mint '{"token_series_id": "490641", "receiver_id": "bob.near"}' --depositYocto 10000000000000000000000 --accountId bob.near -``` - -:::note -In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. -::: - - - - - -```bash -near call thomasettorreiv.mintbase1.near nft_batch_mint '{"num_to_mint": 1, "owner_id": "bob.near", "metadata": {}}' --accountId bob.near --depositYocto 10000000000000000000000 -``` - -:::note -In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. -::: - - - - - ---- - -## Buy a NFT - - - - -```bash -near call x.paras.near buy '{"token_series_id": "299102", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.20574 -``` - -**Example response:** - -```json -"299102:1" -``` - - - - - - -```bash -near call simple.market.mintbase1.near buy '{"nft_contract_id": "rubennnnnnnn.mintbase1.near", "token_id": "38"}' --accountId bob.near --deposit 0.001 -``` - -**Example response:** - -```json -{ - "payout": { - "rub3n.near": "889200000000000000000", - "rubenm4rcus.near": "85800000000000000000" - } -} -``` - - - - - - ---- - -## Query NFT data - - - - -```bash -near view nft.primitives.near nft_token '{"token_id": "1"}' -``` - -**Example response:** - -```json -{ - "token_id": "1", - "owner_id": "bob.near", - "metadata": { - "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - "description": "string", // free-form description - "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage - "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - "copies": 1, // number of copies of this set of metadata in existence when token was minted. - "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds - "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds - "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds - "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds - "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. - "reference": "string", // URL to an off-chain JSON file with more info. - "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. - } -} -``` - - - - - - -```bash -near view x.paras.near nft_token '{"token_id": "84686:1154"}' -``` - -**Example response:** - -```json -{ - "token_id": "84686:1154", - "owner_id": "bob.near", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": null, - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": "1642053411068358156", - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null - }, - "approved_account_ids": {} -} -``` - - - - - - -```bash -near view anthropocene.mintbase1.near nft_token '{"token_id": "17960"}' -``` - -**Example response:** - -```json -{ - "token_id": "17960", - "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", - "approved_account_ids": {}, - "metadata": { - "title": null, - "description": null, - "media": null, - "media_hash": null, - "copies": 1, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", - "reference_hash": null - }, - "royalty": { - "split_between": { - "seventhage.near": { - "numerator": 10000 - } - }, - "percentage": { - "numerator": 100 - } - }, - "split_owners": null, - "minter": "anthropocene.seventhage.near", - "loan": null, - "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, - "origin_key": null -} -``` - - -:::note -When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. -::: - - - - - ---- - -## Transfer a NFT - - - - -```bash -near call nft.primitives.near nft_transfer '{"token_id": "1", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 -``` - - - - - -```bash -near call x.paras.near nft_transfer '{"token_id": "490641", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 -``` - - - - - -```bash -near call thomasettorreiv.mintbase1.near nft_transfer '{"token_id": "490641" "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 -``` - - - - - ---- - -## List a NFT for sale - -Basic NFT contracts following [the NEP-171 and NEP-177 standards](https://nomicon.io/Standards/Tokens/NonFungibleToken) do not implement marketplace functionality. - -For this purpose, there are ecosystem apps such as [Paras](https://paras.id/) or [Mintbase](https://www.mintbase.xyz/), that use dedicated marketplace contracts. - -In order to put a NFT for a sale on a marketplace you need to do two actions: - -1. Cover data storage costs in the marketplace contract. -2. Approve the marketplace to sell the NFT in your NFT contract. - - - - - -```bash -near call marketplace.paras.near storage_deposit '{"receiver_id": "bob.near"}' --accountId bob.near --deposit 0.00939 - -near call nft.primitives.near nft_approve '{"token_id": "1e95238d266e5497d735eb30", "account_id": "marketplace.paras.near", "msg": {"price": "200000000000000000000000", "market_type": "sale", "ft_token_id": "near"}}' --accountId bob.near -``` - -Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. - - - - - -```bash -near call simple.market.mintbase1.near deposit_storage '{"autotransfer": "true"}' --accountId bob.near --deposit 0.00939 - -near call nft.primitives.near nft_approve '{"token_id": "3c46b76cbd48e65f2fc88473", "account_id": "simple.market.mintbase1.near", "msg": {"price": "200000000000000000000000"}}' --accountId bob.near -``` - -Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. - - - - - -:::info -More examples of how to mint NFT, query metadata, attach NFTs to a contract call using `near-cli` you can [read here](/develop/relevant-contracts/nft). -::: diff --git a/docs/7.primitives/nft/interacting/near-cli/buy.md b/docs/7.primitives/nft/interacting/near-cli/buy.md new file mode 100644 index 00000000000..27afd9300b3 --- /dev/null +++ b/docs/7.primitives/nft/interacting/near-cli/buy.md @@ -0,0 +1,39 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```bash +near call x.paras.near buy '{"token_series_id": "299102", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.20574 +``` + +**Example response:** + +```json +"299102:1" +``` + + + + + + +```bash +near call simple.market.mintbase1.near buy '{"nft_contract_id": "rubennnnnnnn.mintbase1.near", "token_id": "38"}' --accountId bob.near --deposit 0.001 +``` + +**Example response:** + +```json +{ + "payout": { + "rub3n.near": "889200000000000000000", + "rubenm4rcus.near": "85800000000000000000" + } +} +``` + + + + diff --git a/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md b/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md new file mode 100644 index 00000000000..36cc5c8f494 --- /dev/null +++ b/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md @@ -0,0 +1,28 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```bash +near call marketplace.paras.near storage_deposit '{"receiver_id": "bob.near"}' --accountId bob.near --deposit 0.00939 + +near call nft.primitives.near nft_approve '{"token_id": "1e95238d266e5497d735eb30", "account_id": "marketplace.paras.near", "msg": {"price": "200000000000000000000000", "market_type": "sale", "ft_token_id": "near"}}' --accountId bob.near +``` + +Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. + + + + + +```bash +near call simple.market.mintbase1.near deposit_storage '{"autotransfer": "true"}' --accountId bob.near --deposit 0.00939 + +near call nft.primitives.near nft_approve '{"token_id": "3c46b76cbd48e65f2fc88473", "account_id": "simple.market.mintbase1.near", "msg": {"price": "200000000000000000000000"}}' --accountId bob.near +``` + +Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. + + + diff --git a/docs/7.primitives/nft/interacting/near-cli/mint.md b/docs/7.primitives/nft/interacting/near-cli/mint.md new file mode 100644 index 00000000000..d58b34056d1 --- /dev/null +++ b/docs/7.primitives/nft/interacting/near-cli/mint.md @@ -0,0 +1,37 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```bash +near call nft.primitives.near nft_mint '{"token_id": "1", "receiver_id": "bob.near", "token_metadata": {"title": "NFT Primitive Token", "description": "Awesome NFT Primitive Token", "media": "string"}}' --depositYocto 10000000000000000000000, --accountId bob.near +``` + + + + + +```bash +near call x.paras.near nft_mint '{"token_series_id": "490641", "receiver_id": "bob.near"}' --depositYocto 10000000000000000000000 --accountId bob.near +``` + +:::note +In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. +::: + + + + + +```bash +near call thomasettorreiv.mintbase1.near nft_batch_mint '{"num_to_mint": 1, "owner_id": "bob.near", "metadata": {}}' --accountId bob.near --depositYocto 10000000000000000000000 +``` + +:::note +In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. +::: + + + + diff --git a/docs/7.primitives/nft/interacting/near-cli/query.md b/docs/7.primitives/nft/interacting/near-cli/query.md new file mode 100644 index 00000000000..38de189a035 --- /dev/null +++ b/docs/7.primitives/nft/interacting/near-cli/query.md @@ -0,0 +1,121 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```bash +near view nft.primitives.near nft_token '{"token_id": "1"}' +``` + +**Example response:** + +```json +{ + "token_id": "1", + "owner_id": "bob.near", + "metadata": { + "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" + "description": "string", // free-form description + "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage + "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + "copies": 1, // number of copies of this set of metadata in existence when token was minted. + "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds + "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds + "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds + "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds + "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. + "reference": "string", // URL to an off-chain JSON file with more info. + "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + } +} +``` + + + + + + +```bash +near view x.paras.near nft_token '{"token_id": "84686:1154"}' +``` + +**Example response:** + +```json +{ + "token_id": "84686:1154", + "owner_id": "bob.near", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": null, + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": "1642053411068358156", + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null + }, + "approved_account_ids": {} +} +``` + + + + + + +```bash +near view anthropocene.mintbase1.near nft_token '{"token_id": "17960"}' +``` + +**Example response:** + +```json +{ + "token_id": "17960", + "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", + "approved_account_ids": {}, + "metadata": { + "title": null, + "description": null, + "media": null, + "media_hash": null, + "copies": 1, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", + "reference_hash": null + }, + "royalty": { + "split_between": { + "seventhage.near": { + "numerator": 10000 + } + }, + "percentage": { + "numerator": 100 + } + }, + "split_owners": null, + "minter": "anthropocene.seventhage.near", + "loan": null, + "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, + "origin_key": null +} +``` + + +:::note +When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. +::: + + + diff --git a/docs/7.primitives/nft/interacting/near-cli/transfer.md b/docs/7.primitives/nft/interacting/near-cli/transfer.md new file mode 100644 index 00000000000..b4ef6ce60c2 --- /dev/null +++ b/docs/7.primitives/nft/interacting/near-cli/transfer.md @@ -0,0 +1,28 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```bash +near call nft.primitives.near nft_transfer '{"token_id": "1", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 +``` + + + + + +```bash +near call x.paras.near nft_transfer '{"token_id": "490641", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 +``` + + + + + +```bash +near call thomasettorreiv.mintbase1.near nft_transfer '{"token_id": "490641" "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 +``` + + + diff --git a/docs/7.primitives/nft/interacting/smart-contract.md b/docs/7.primitives/nft/interacting/smart-contract.md deleted file mode 100644 index 3b147a41ba3..00000000000 --- a/docs/7.primitives/nft/interacting/smart-contract.md +++ /dev/null @@ -1,272 +0,0 @@ ---- -id: smart-contract -title: Smart Contract -hide_table_of_contents: false ---- - -This section will explain how a smart contract can mint, buy, transfer and query NFTs. - -:::tip -If you are looking to create your own NFT contract please check the [Example implementation](https://github.com/near-examples/NFT) and the [NFT Zero to Hero Tutorial](https://docs.near.org/tutorials/nfts/introduction) -::: - ---- - -### Base Contract - -The examples assume that the contract is defined as follows: - -```rust -use near_contract_standards::non_fungible_token::{Token, TokenId}; -use near_sdk::ext_contract; -use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; -use near_sdk::{env, log, near_bindgen, AccountId, Promise, PromiseError}; - -const NFT_CONTRACT: &str = "x.paras.near"; - -// Define the contract structure -#[near_bindgen] -#[derive(BorshDeserialize, BorshSerialize)] -pub struct Contract { - nft_contract: AccountId -} - -impl Default for Contract { - // The default trait with which to initialize the contract - fn default() -> Self { - Self { - nft_contract: NFT_CONTRACT.parse().unwrap(), - } - } -} - -// Implement the contract structure -#[near_bindgen] -impl Contract {} -``` - ---- - -## Mint a NFT - -
- -Minting in Paras - - -In case with Paras NFT contract before minting NFT token you may need to create token series from your contract account. You can do it via [Paras UI](https://paras.id/en) or use `near-cli`: - -```bash -# Example of the command creating token series on Paras -near call x.paras.near nft_create_series '{"token_metadata": {"title": "NFT #1", "media": "bafybeibnpe5x6euhjtn5qrayfgeemxyru7ho3yhdyaifv7gsvdn46j6vzi", "reference": "bafybeif6cjn5bmdp7w5x2jms2xlz64qmp7crd5z77rl3iy3m54mlustdiu", "copies": 10}, "royalty": {"": 1000}, "price": null}' --accountId --depositYocto 6090000000000000000000 -``` - -
- - - -```rust -// Validator interface, for cross-contract calls -#[ext_contract(ext_nft_contract)] -trait ExternalNftContract { - fn nft_mint(&self, token_series_id: String, receiver_id: AccountId) -> Promise; -} - -// Implement the contract structure -#[near_bindgen] -impl Contract { - #[payable] - pub fn nft_mint(&mut self, token_series_id: String, receiver_id: AccountId) -> Promise { - let promise = ext_nft_contract::ext(self.nft_contract.clone()) - .with_static_gas(Gas(30*TGAS)) - .with_attached_deposit(env::attached_deposit()) - .nft_mint(token_series_id, receiver_id); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .with_static_gas(Gas(30*TGAS)) - .nft_mint_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn nft_mint_callback(&self, #[callback_result] call_result: Result) -> Option { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - return None; - } - - // Return the token data - let token_id: TokenId = call_result.unwrap(); - return Some(token_id); - } -} -``` - -:::info -Values of gas and deposit might vary depending on which NFT contract you are calling. -::: - ---- - -## Buy a NFT - -This is an example on how you can make your smart contract buy a NFT on some marketplace (Paras this case). - -:::info -Please note that in this example the contract will be the owner of the NFT, however, some marketplaces allow you to buy NFT for somebody else. -::: - -```rust -const NFT_MARKETPLACE_CONTRACT: &str = "paras-marketplace-v2.testnet"; - -// Define the contract structure -#[near_bindgen] -#[derive(BorshDeserialize, BorshSerialize)] -pub struct Contract { - nft_marketplace_contract: AccountId -} - -impl Default for Contract { - // The default trait with which to initialize the contract - fn default() -> Self { - Self { - nft_marketplace_contract: NFT_MARKETPLACE_CONTRACT.parse().unwrap() - } - } -} - -// Validator interface, for cross-contract calls -#[ext_contract(ext_nft_contract)] -trait ExternalNftContract { - fn buy(&self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise; -} - -// Implement the contract structure -#[near_bindgen] -impl Contract { - #[payable] - pub fn buy(&mut self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise { - let promise = ext_nft_contract::ext(self.nft_marketplace_contract.clone()) - .with_static_gas(Gas(30*TGAS)) - .with_attached_deposit(env::attached_deposit()) - .buy(nft_contract_id, token_id, ft_token_id, price); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .with_static_gas(Gas(30*TGAS)) - .buy_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn buy_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - } - } -} -``` - ---- - -## Query NFT data - -```rust -// Validator interface, for cross-contract calls -#[ext_contract(ext_nft_contract)] -trait ExternalNftContract { - fn nft_token(&self, token_id: TokenId) -> Promise; -} - -// Implement the contract structure -#[near_bindgen] -impl Contract { - pub fn nft_token(&self, token_id: TokenId) -> Promise { - let promise = ext_nft_contract::ext(self.nft_contract.clone()) - .nft_token(token_id); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .nft_token_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn nft_token_callback(&self, #[callback_result] call_result: Result) -> Option { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - return None; - } - - // Return the token data - let token_data: Token = call_result.unwrap(); - return Some(token_data); - } -} -``` - ---- - -## Transfer a NFT - -This is how a contract can transfer an NFT. - -:::info -Please notice that a contract can only transfer an NFT that they own, or an NFT that they were approved to transfer. -::: - -```rust -const YOCTO_NEAR: u128 = 1; - -#[ext_contract(ext_nft_contract)] -trait ExternalNftContract { - fn nft_transfer(&self, receiver_id: AccountId, token_id: TokenId) -> Promise; -} - -impl Contract { - #[payable] - pub fn nft_transfer(&mut self, receiver_id: AccountId, token_id: TokenId) -> Promise { - let promise = ext_nft_contract::ext(self.nft_contract.clone()) - .with_attached_deposit(YOCTO_NEAR) - .nft_transfer(receiver_id, token_id); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .nft_transfer_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn nft_transfer_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - } - } -} -``` - ---- - -## List a NFT for sale - -Due to the specifics of putting a token up for sale on a NFT marketplace (more precisely, the need for the owner of the token to sign an approval transaction), you need to do this on the client side. - -Check out how to do it from a [NEAR component](/primitives/nft/interacting/bos#list-a-nft-up-for-a-sale) or from a [web app](/primitives/nft/interacting/web-app#list-a-nft-up-for-a-sale). - ---- - -## Additional resources - - -:::info - Read more about cross contract calls [here](https://docs.near.org/tutorials/examples/xcc). -::: - -:::tip -Example of [how to attach NFTs to a contract call](/develop/relevant-contracts/nft#attaching-nfts-to-a-call). -::: \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/smart-contract/buy.md b/docs/7.primitives/nft/interacting/smart-contract/buy.md new file mode 100644 index 00000000000..82e33820564 --- /dev/null +++ b/docs/7.primitives/nft/interacting/smart-contract/buy.md @@ -0,0 +1,65 @@ +import {Github} from "@site/src/components/codetabs"; + +This is an example on how you can make your smart contract buy a NFT on some marketplace (Paras this case). + +:::info +Please note that in this example the contract will be the owner of the NFT, however, some marketplaces allow you to buy NFT for somebody else. +::: + +```rust +const NFT_MARKETPLACE_CONTRACT: &str = "paras-marketplace-v2.testnet"; + +// Define the contract structure +#[near_bindgen] +#[derive(BorshDeserialize, BorshSerialize)] +pub struct Contract { + nft_marketplace_contract: AccountId +} + +impl Default for Contract { + // The default trait with which to initialize the contract + fn default() -> Self { + Self { + nft_marketplace_contract: NFT_MARKETPLACE_CONTRACT.parse().unwrap() + } + } +} + +// Validator interface, for cross-contract calls +#[ext_contract(ext_nft_contract)] +trait ExternalNftContract { + fn buy(&self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise; +} + +// Implement the contract structure +#[near_bindgen] +impl Contract { + #[payable] + pub fn buy(&mut self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise { + let promise = ext_nft_contract::ext(self.nft_marketplace_contract.clone()) + .with_static_gas(Gas(30*TGAS)) + .with_attached_deposit(env::attached_deposit()) + .buy(nft_contract_id, token_id, ft_token_id, price); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .with_static_gas(Gas(30*TGAS)) + .buy_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn buy_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + } + } +} +``` + +Full smart contract code you may find below. + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/smart-contract/mint.md b/docs/7.primitives/nft/interacting/smart-contract/mint.md new file mode 100644 index 00000000000..bffdd89e53e --- /dev/null +++ b/docs/7.primitives/nft/interacting/smart-contract/mint.md @@ -0,0 +1,64 @@ +import {Github} from "@site/src/components/codetabs"; + +
+ +Minting in Paras + + +In case with Paras NFT contract before minting NFT token you may need to create token series from your contract account. You can do it via [Paras UI](https://paras.id/en) or use `near-cli`: + +```bash +# Example of the command creating token series on Paras +near call x.paras.near nft_create_series '{"token_metadata": {"title": "NFT #1", "media": "bafybeibnpe5x6euhjtn5qrayfgeemxyru7ho3yhdyaifv7gsvdn46j6vzi", "reference": "bafybeif6cjn5bmdp7w5x2jms2xlz64qmp7crd5z77rl3iy3m54mlustdiu", "copies": 10}, "royalty": {"": 1000}, "price": null}' --accountId --depositYocto 6090000000000000000000 +``` + +
+ +```rust +// Validator interface, for cross-contract calls +#[ext_contract(ext_nft_contract)] +trait ExternalNftContract { + fn nft_mint(&self, token_series_id: String, receiver_id: AccountId) -> Promise; +} + +// Implement the contract structure +#[near_bindgen] +impl Contract { + #[payable] + pub fn nft_mint(&mut self, token_series_id: String, receiver_id: AccountId) -> Promise { + let promise = ext_nft_contract::ext(self.nft_contract.clone()) + .with_static_gas(Gas(30*TGAS)) + .with_attached_deposit(env::attached_deposit()) + .nft_mint(token_series_id, receiver_id); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .with_static_gas(Gas(30*TGAS)) + .nft_mint_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn nft_mint_callback(&self, #[callback_result] call_result: Result) -> Option { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + return None; + } + + // Return the token data + let token_id: TokenId = call_result.unwrap(); + return Some(token_id); + } +} +``` + +:::info +Values of gas and deposit might vary depending on which NFT contract you are calling. +::: + +Full smart contract code you may find below. + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/smart-contract/query.md b/docs/7.primitives/nft/interacting/smart-contract/query.md new file mode 100644 index 00000000000..32b9fe02730 --- /dev/null +++ b/docs/7.primitives/nft/interacting/smart-contract/query.md @@ -0,0 +1,42 @@ +import {Github} from "@site/src/components/codetabs"; + +```rust +// Validator interface, for cross-contract calls +#[ext_contract(ext_nft_contract)] +trait ExternalNftContract { + fn nft_token(&self, token_id: TokenId) -> Promise; +} + +// Implement the contract structure +#[near_bindgen] +impl Contract { + pub fn nft_token(&self, token_id: TokenId) -> Promise { + let promise = ext_nft_contract::ext(self.nft_contract.clone()) + .nft_token(token_id); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .nft_token_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn nft_token_callback(&self, #[callback_result] call_result: Result) -> Option { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + return None; + } + + // Return the token data + let token_data: Token = call_result.unwrap(); + return Some(token_data); + } +} +``` + +Full smart contract code you may find below. + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/smart-contract/transfer.md b/docs/7.primitives/nft/interacting/smart-contract/transfer.md new file mode 100644 index 00000000000..b64dc0d6a39 --- /dev/null +++ b/docs/7.primitives/nft/interacting/smart-contract/transfer.md @@ -0,0 +1,42 @@ +import {Github} from "@site/src/components/codetabs"; + +:::info +Please notice that a contract can only transfer an NFT that they own, or an NFT that they were approved to transfer. +::: + +```rust +const YOCTO_NEAR: u128 = 1; + +#[ext_contract(ext_nft_contract)] +trait ExternalNftContract { + fn nft_transfer(&self, receiver_id: AccountId, token_id: TokenId) -> Promise; +} + +impl Contract { + #[payable] + pub fn nft_transfer(&mut self, receiver_id: AccountId, token_id: TokenId) -> Promise { + let promise = ext_nft_contract::ext(self.nft_contract.clone()) + .with_attached_deposit(YOCTO_NEAR) + .nft_transfer(receiver_id, token_id); + + return promise.then( // Create a promise to callback query_greeting_callback + Self::ext(env::current_account_id()) + .nft_transfer_callback() + ) + } + + #[private] // Public - but only callable by env::current_account_id() + pub fn nft_transfer_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { + // Check if the promise succeeded + if call_result.is_err() { + log!("There was an error contacting NFT contract"); + } + } +} +``` + +Full smart contract code you may find below. + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/web-app.md b/docs/7.primitives/nft/interacting/web-app.md deleted file mode 100644 index 8e0847fe9a2..00000000000 --- a/docs/7.primitives/nft/interacting/web-app.md +++ /dev/null @@ -1,778 +0,0 @@ ---- -id: web-app -title: Web Application -hide_table_of_contents: false ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -This section describes how to interact with NFT contracts from a web app. - -:::info -All the examples are using a `Wallet` object, which comes from our [basic template](https://github.com/near-examples/hello-near-js/blob/master/frontend/near-wallet.js) -::: - ---- - -## Mint a NFT - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "nft.primitives.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_mint', - args: { - token_id: "1", - receiver_id: "bob.near", - token_metadata: { - title: "NFT Primitive Token", - description: "Awesome NFT Primitive Token", - media: "string", // URL to associated media, preferably to decentralized, content-addressed storage - } - }, - contractId: CONTRACT_ADDRESS, - deposit: 10000000000000000000000 -}); -``` - - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "x.paras.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_mint', - args: { - token_series_id: "490641", - receiver_id: "bob.near", - }, - contractId: CONTRACT_ADDRESS, - deposit: 10000000000000000000000 // Depends on your NFT metadata -}); -``` - -:::note -In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. -::: - - - - - -By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_batch_mint', - args: { - num_to_mint: 1, - owner_id: "bob.near", - metadata: {}, - }, - contractId: CONTRACT_ADDRESS, - deposit: 10000000000000000000000 // Depends on your NFT metadata -}); -``` - -:::note -In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. -::: - -By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/mint) - -```js -import { useState } from 'react'; -import { useWallet } from '@mintbase-js/react'; -import { execute, mint, MintArgs } from '@mintbase-js/sdk'; - - -export const MintComponent = ({ media, reference, contractAddress, owner }: MintArgs): JSX.Element => { - - const { selector } = useWallet(); - - const handleMint = async (): Promise => { - - const wallet = await selector.wallet(); - - await execute( - mint({ contractAddress: contractAddress, metadata: { media, reference }, ownerId: owner }) - ); - - } - - return ( -
- -
- ); -}; -``` - -
- -
- ---- - -## Buy a NFT - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "x.paras.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_buy', - args: { - token_series_id: "299102", - receiver_id: "bob.near", - }, - contractId: CONTRACT_ADDRESS, - deposit: 205740000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost -}); -``` - -**Example response:** - -```json -"299102:1" -``` - - - - - - -By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'buy', - args: { - nft_contract_id: "rubennnnnnnn.mintbase1.near", - token_id: "38" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1000000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost (optional) -}); -``` - -**Example response:** - -```json -{ - "payout": { - "rub3n.near": "889200000000000000000", - "rubenm4rcus.near": "85800000000000000000" - } -} -``` - - -By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/buy) - -```js -import { useState } from 'react'; -import { useWallet } from '@mintbase-js/react'; -import { execute, burn, BuyArgs } from '@mintbase-js/sdk'; - - -export const BuyComponent = ({ contractAddress, price, tokenId, affiliateAccount, marketId }:BuyArgs): JSX.Element => { - - const { selector } = useWallet(); - - const handleBuy = async (): Promise => { - - const wallet = await selector.wallet(); - - const buyArgs = {contractAddress: contractAddress, tokenId: tokenId, affiliateAccount: affiliateAccount , marketId:marketId, price:price } - - await execute( - {wallet}, - buy(buyArgs) - ); - - } - - return ( -
- -
- ); -}; -``` - -
- -
- ---- - -## Query NFT data - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "nft.primitives.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -const response = await wallet.viewMethod({ - method: 'nft_token', - args: { - token_id: "1" - } -}); -``` - -**Example response:** - -```json -{ - "token_id": "1", - "owner_id": "bob.near", - "metadata": { - "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - "description": "string", // free-form description - "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage - "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - "copies": 1, // number of copies of this set of metadata in existence when token was minted. - "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds - "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds - "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds - "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds - "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. - "reference": "string", // URL to an off-chain JSON file with more info. - "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. - } -} -``` - - - - - - -By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "x.paras.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -const response = await wallet.viewMethod({ - method: 'nft_token', - args: { - token_id: "84686:1154" - } -}); -``` - -**Example response:** - -```json -{ - "token_id": "84686:1154", - "owner_id": "bob.near", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": null, - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": "1642053411068358156", - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null - }, - "approved_account_ids": {} -} -``` - - -By calling a Paras API method - -```js -const tokenData = fetch("https://api-v2-mainnet.paras.id/token?token_id=84686:1154"); -``` - -**Example response:** - -```json -{ - "status": 1, - "data": { - "results": [ - { - "_id": "61dfbf27284abc1cc0b87c9d", - "contract_id": "x.paras.near", - "token_id": "84686:1154", - "owner_id": "bob.near", - "token_series_id": "84686", - "edition_id": "1154", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": "Holding this silver coin in your wallet will bring you health and happiness \uD83D\uDE0A", - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null, - "collection": "Tokenfox Collection Cards", - "collection_id": "tokenfox-collection-cards-by-tokenfoxnear", - "creator_id": "tokenfox.near", - "blurhash": "U7F~gc00_3D%00~q4n%M_39F-;RjM{xuWBRj", - "score": 0, - "mime_type": "image/png" - }, - "royalty": { - "tokenfox.near": 1000 - }, - "price": null, - "approval_id": null, - "ft_token_id": null, - "has_price": null, - "is_creator": true, - "total_likes": 8, - "likes": null, - "categories": [], - "view": 4 - } - ], - "count": 1, - "skip": 0, - "limit": 10 - } -} -``` - - -:::info -See the [Paras API documentation](https://parashq.github.io/) for the full list of methods. -::: - -:::note -When you call Paras smart contract method it returns data that are stored in the Paras NFT smart contract. It means a response contains only data about NFTs which were minted via Paras NFT contract. - -When you call Paras API methods it returns data from other NFT contracts as well, due to the work of the indexer. It means you might want to pass more parameters like `contract_id` or `owner_id` to make the response more accurate. -::: - - - - - -By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "anthropocene.mintbase1.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -const response = await wallet.viewMethod({ - method: 'nft_token', - args: { - token_id: "17960" - } -}); -``` - -**Example response:** - -```json -{ - "token_id": "17960", - "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", - "approved_account_ids": {}, - "metadata": { - "title": null, - "description": null, - "media": null, - "media_hash": null, - "copies": 1, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", - "reference_hash": null - }, - "royalty": { - "split_between": { - "seventhage.near": { - "numerator": 10000 - } - }, - "percentage": { - "numerator": 100 - } - }, - "split_owners": null, - "minter": "anthropocene.seventhage.near", - "loan": null, - "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, - "origin_key": null -} -``` - - -:::note -When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. -::: - -By calling a Mintbase GraphQL API method - -```js -const tokenData = fetch("https://graph.mintbase.xyz", { - method: "POST", - headers: { - "mb-api-key": "anon", - "Content-Type": "application/json", - "x-hasura-role": "anonymous", - }, - body: JSON.stringify({ - query: ` - query getToken{ - tokens: nft_tokens( - where: { - token_id: { _eq: "84686:1154" } - } - ) { - tokenId: token_id - ownerId: owner - contractId: nft_contract_id - reference - issuedAt: issued_at - copies - metadataId: metadata_id - } - } - `, - }), -}); -``` - -**Example response:** - -```json -{ - "ok": true, - "status": 200, - "contentType": "application/json", - "body": { - "data": { - "tokens": [ - { - "tokenId": "84686:1154", - "ownerId": "bob.near", - "contractId": "x.paras.near", - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "issuedAt": "2022-01-13T05:56:51.068358", - "copies": 4063, - "metadataId": "x.paras.near:5210047642790498956c9669d6a37b98" - } - ] - } - } -} -``` - - -:::note -In the future, users may be required to register using an api key. For now, simply passing the valueanon for `mb-api-key` will work. -::: - -By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/data/api/tokenbyid) - -```js -import { tokenById } from '@mintbase-js/data' - -const { data, error } = await tokenById( '1','rub3n.testnet'); - -if (error) {console.log('error', error)} - - -console.log(data.tokenData[0]) // => token metadata -``` - - - - - ---- - -## Transfer a NFT - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "nft.primitives.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_transfer', - args: { - token_id: "1", - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1 -}); -``` - - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "x.paras.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_transfer', - args: { - token_id: "490641", - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1 -}); -``` - - - - - -By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'nft_transfer', - args: { - token_id: "490641", - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1 -}); -``` - -By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/transfer) - -```js -import { useState } from 'react'; -import { useWallet } from '@mintbase-js/react'; -import { execute, transfer, TransferArgs } from '@mintbase-js/sdk'; - -const TransferComponent = ({ tokenId, contractAddress }: TransferArgs): JSX.Element => { - const { selector, activeAccountId } = useWallet(); - - const handleTransfer = async (): Promise => { - const wallet = await selector.wallet(); - - const transferArgs: TransferArgs = { - contractAddress: contractAddress, - transfers: [{ - receiverId: 'mb_carol.testnet', - tokenId: token.tokenId, - }], - } - - await execute( - { wallet }, - transfer(transferArgs), - ); - }; - - return ( -
- -
- ); -} -``` - -
- -
- ---- - -## List a NFT for sale - -Basic NFT contracts following [the NEP-171 and NEP-177 standards](https://nomicon.io/Standards/Tokens/NonFungibleToken) do not implement marketplace functionality. - -For this purpose, there are ecosystem apps such as [Paras](https://paras.id/) or [Mintbase](https://www.mintbase.xyz/), that use dedicated marketplace contracts. - -In order to put a NFT for a sale on a marketplace you need to do two actions: - -1. Cover data storage costs in the marketplace contract. -2. Approve the marketplace to sell the NFT in your NFT contract. - - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "marketplace.paras.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'storage_deposit', - args: { - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - gas: 300000000000000, // attached GAS (optional) - deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) -}); - -await wallet.callMethod({ - method: 'nft_approve', - args: { - token_id: "1e95238d266e5497d735eb30", - account_id: "marketplace.paras.near", - msg: { - price: "200000000000000000000000", - market_type: "sale", - ft_token_id: "near" - } - }, - contractId: "nft.primitives.near" -}); -``` - -Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. - - - - - -```js -import { Wallet } from './near-wallet'; - -const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; -const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - -await wallet.callMethod({ - method: 'deposit_storage', - args: { - autotransfer: true - }, - contractId: CONTRACT_ADDRESS, - gas: 300000000000000, // attached GAS (optional) - deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) -}); - -await wallet.callMethod({ - method: 'nft_approve', - args: { - args: { - token_id: "3c46b76cbd48e65f2fc88473", - account_id: "simple.market.mintbase1.near", - msg: { - price: "200000000000000000000000" - } - }, - }, - contractId: "nft.primitives.near" -}); -``` - -Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. - -By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/list) - -```js -import { useState } from 'react'; -import { useWallet } from '@mintbase-js/react'; -import { execute, list, ListArgs } from '@mintbase-js/sdk'; - - -export const ListComponent = ({ contractAddress, marketAddress , tokenId, price }:ListArgs):JSX.Element => { - - const { selector } = useWallet(); - - const handleList = async (): Promise => { - const wallet = await selector.wallet(); - - await execute( - {wallet}, - list({ - contractAddress: nftContractId, - marketAddress: marketId, - tokenId: tokenId, - price: price - }) - ) - } - - return ( -
- -
- ); -}; -``` - -
- -
diff --git a/docs/7.primitives/nft/interacting/web-app/buy.md b/docs/7.primitives/nft/interacting/web-app/buy.md new file mode 100644 index 00000000000..e6486fb52f2 --- /dev/null +++ b/docs/7.primitives/nft/interacting/web-app/buy.md @@ -0,0 +1,105 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import {Github} from "@site/src/components/codetabs"; + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "x.paras.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_buy', + args: { + token_series_id: "299102", + receiver_id: "bob.near", + }, + contractId: CONTRACT_ADDRESS, + deposit: 205740000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost +}); +``` + +**Example response:** + +```json +"299102:1" +``` + + + + + + +By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'buy', + args: { + nft_contract_id: "rubennnnnnnn.mintbase1.near", + token_id: "38" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1000000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost (optional) +}); +``` + +**Example response:** + +```json +{ + "payout": { + "rub3n.near": "889200000000000000000", + "rubenm4rcus.near": "85800000000000000000" + } +} +``` + + +By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/buy) + +```js +import { useState } from 'react'; +import { useWallet } from '@mintbase-js/react'; +import { execute, burn, BuyArgs } from '@mintbase-js/sdk'; + + +export const BuyComponent = ({ contractAddress, price, tokenId, affiliateAccount, marketId }:BuyArgs): JSX.Element => { + const { selector } = useWallet(); + + const handleBuy = async (): Promise => { + const wallet = await selector.wallet(); + const buyArgs = {contractAddress: contractAddress, tokenId: tokenId, affiliateAccount: affiliateAccount , marketId:marketId, price:price } + + await execute( + { wallet }, + buy(buyArgs) + ); + } + + return ( +
+ +
+ ); +}; +``` + +
+
+ +All the examples are using a `Wallet` object, which comes from our basic template: + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/web-app/list-for-sale.md b/docs/7.primitives/nft/interacting/web-app/list-for-sale.md new file mode 100644 index 00000000000..941f0ad18e5 --- /dev/null +++ b/docs/7.primitives/nft/interacting/web-app/list-for-sale.md @@ -0,0 +1,119 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import {Github} from "@site/src/components/codetabs"; + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "marketplace.paras.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'storage_deposit', + args: { + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + gas: 300000000000000, // attached GAS (optional) + deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) +}); + +await wallet.callMethod({ + method: 'nft_approve', + args: { + token_id: "1e95238d266e5497d735eb30", + account_id: "marketplace.paras.near", + msg: { + price: "200000000000000000000000", + market_type: "sale", + ft_token_id: "near" + } + }, + contractId: "nft.primitives.near" +}); +``` + +Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. + + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'deposit_storage', + args: { + autotransfer: true + }, + contractId: CONTRACT_ADDRESS, + gas: 300000000000000, // attached GAS (optional) + deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) +}); + +await wallet.callMethod({ + method: 'nft_approve', + args: { + args: { + token_id: "3c46b76cbd48e65f2fc88473", + account_id: "simple.market.mintbase1.near", + msg: { + price: "200000000000000000000000" + } + }, + }, + contractId: "nft.primitives.near" +}); +``` + +Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. + +By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/list) + +```js +import { useState } from 'react'; +import { useWallet } from '@mintbase-js/react'; +import { execute, list, ListArgs } from '@mintbase-js/sdk'; + +export const ListComponent = ({ contractAddress, marketAddress , tokenId, price }: ListArgs):JSX.Element => { + const { selector } = useWallet(); + + const handleList = async (): Promise => { + const wallet = await selector.wallet(); + + await execute( + { wallet }, + list({ + contractAddress: nftContractId, + marketAddress: marketId, + tokenId: tokenId, + price: price + }) + ) + } + + return ( +
+ +
+ ); +}; +``` + +
+
+ +All the examples are using a `Wallet` object, which comes from our basic template: + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/web-app/mint.md b/docs/7.primitives/nft/interacting/web-app/mint.md new file mode 100644 index 00000000000..2397f3c6781 --- /dev/null +++ b/docs/7.primitives/nft/interacting/web-app/mint.md @@ -0,0 +1,120 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import {CodeTabs, Github} from "@site/src/components/codetabs"; + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "nft.primitives.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_mint', + args: { + token_id: "1", + receiver_id: "bob.near", + token_metadata: { + title: "NFT Primitive Token", + description: "Awesome NFT Primitive Token", + media: "string", // URL to associated media, preferably to decentralized, content-addressed storage + } + }, + contractId: CONTRACT_ADDRESS, + deposit: 10000000000000000000000 +}); +``` + + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "x.paras.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_mint', + args: { + token_series_id: "490641", + receiver_id: "bob.near", + }, + contractId: CONTRACT_ADDRESS, + deposit: 10000000000000000000000 // Depends on your NFT metadata +}); +``` + +:::note +In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. +::: + + + + + +By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_batch_mint', + args: { + num_to_mint: 1, + owner_id: "bob.near", + metadata: {}, + }, + contractId: CONTRACT_ADDRESS, + deposit: 10000000000000000000000 // Depends on your NFT metadata +}); +``` + +:::note +In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. +::: + +By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/mint) + +```js +import { useState } from 'react'; +import { useWallet } from '@mintbase-js/react'; +import { execute, mint, MintArgs } from '@mintbase-js/sdk'; + + +export const MintComponent = ({ media, reference, contractAddress, owner }: MintArgs): JSX.Element => { + const { selector } = useWallet(); + + const handleMint = async (): Promise => { + const wallet = await selector.wallet(); + + await execute( + mint({ contractAddress, metadata: { media, reference }, ownerId: owner }) + ); + } + + return ( +
+ +
+ ); +}; +``` + +
+ +
+ +All the examples are using a `Wallet` object, which comes from our basic template: + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/web-app/query.md b/docs/7.primitives/nft/interacting/web-app/query.md new file mode 100644 index 00000000000..dff303acb1b --- /dev/null +++ b/docs/7.primitives/nft/interacting/web-app/query.md @@ -0,0 +1,306 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import {Github} from "@site/src/components/codetabs"; + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "nft.primitives.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +const response = await wallet.viewMethod({ + method: 'nft_token', + args: { + token_id: "1" + } +}); +``` + +**Example response:** + +```json +{ + "token_id": "1", + "owner_id": "bob.near", + "metadata": { + "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" + "description": "string", // free-form description + "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage + "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. + "copies": 1, // number of copies of this set of metadata in existence when token was minted. + "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds + "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds + "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds + "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds + "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. + "reference": "string", // URL to an off-chain JSON file with more info. + "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. + } +} +``` + + + + + +By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "x.paras.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +const response = await wallet.viewMethod({ + method: 'nft_token', + args: { + token_id: "84686:1154" + } +}); +``` + +**Example response:** + +```json +{ + "token_id": "84686:1154", + "owner_id": "bob.near", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": null, + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": "1642053411068358156", + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null + }, + "approved_account_ids": {} +} +``` + +By calling a Paras API method + +```js +const tokenData = fetch("https://api-v2-mainnet.paras.id/token?token_id=84686:1154"); +``` + +**Example response:** + +```json +{ + "status": 1, + "data": { + "results": [ + { + "_id": "61dfbf27284abc1cc0b87c9d", + "contract_id": "x.paras.near", + "token_id": "84686:1154", + "owner_id": "bob.near", + "token_series_id": "84686", + "edition_id": "1154", + "metadata": { + "title": "Tokenfox Silver Coin #1154", + "description": "Holding this silver coin in your wallet will bring you health and happiness \uD83D\uDE0A", + "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", + "media_hash": null, + "copies": 4063, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "reference_hash": null, + "collection": "Tokenfox Collection Cards", + "collection_id": "tokenfox-collection-cards-by-tokenfoxnear", + "creator_id": "tokenfox.near", + "blurhash": "U7F~gc00_3D%00~q4n%M_39F-;RjM{xuWBRj", + "score": 0, + "mime_type": "image/png" + }, + "royalty": { + "tokenfox.near": 1000 + }, + "price": null, + "approval_id": null, + "ft_token_id": null, + "has_price": null, + "is_creator": true, + "total_likes": 8, + "likes": null, + "categories": [], + "view": 4 + } + ], + "count": 1, + "skip": 0, + "limit": 10 + } +} +``` + +:::info +See the [Paras API documentation](https://parashq.github.io/) for the full list of methods. +::: + +:::note +When you call Paras smart contract method it returns data that are stored in the Paras NFT smart contract. It means a response contains only data about NFTs which were minted via Paras NFT contract. + +When you call Paras API methods it returns data from other NFT contracts as well, due to the work of the indexer. It means you might want to pass more parameters like `contract_id` or `owner_id` to make the response more accurate. +::: + + + + + +By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "anthropocene.mintbase1.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +const response = await wallet.viewMethod({ + method: 'nft_token', + args: { + token_id: "17960" + } +}); +``` + +**Example response:** + +```json +{ + "token_id": "17960", + "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", + "approved_account_ids": {}, + "metadata": { + "title": null, + "description": null, + "media": null, + "media_hash": null, + "copies": 1, + "issued_at": null, + "expires_at": null, + "starts_at": null, + "updated_at": null, + "extra": null, + "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", + "reference_hash": null + }, + "royalty": { + "split_between": { + "seventhage.near": { + "numerator": 10000 + } + }, + "percentage": { + "numerator": 100 + } + }, + "split_owners": null, + "minter": "anthropocene.seventhage.near", + "loan": null, + "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, + "origin_key": null +} +``` + +:::note +When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. +::: + +By calling a Mintbase GraphQL API method + +```js +const tokenData = fetch("https://graph.mintbase.xyz", { + method: "POST", + headers: { + "mb-api-key": "anon", + "Content-Type": "application/json", + "x-hasura-role": "anonymous", + }, + body: JSON.stringify({ + query: ` + query getToken{ + tokens: nft_tokens( + where: { + token_id: { _eq: "84686:1154" } + } + ) { + tokenId: token_id + ownerId: owner + contractId: nft_contract_id + reference + issuedAt: issued_at + copies + metadataId: metadata_id + } + } + `, + }), +}); +``` + +**Example response:** + +```json +{ + "ok": true, + "status": 200, + "contentType": "application/json", + "body": { + "data": { + "tokens": [ + { + "tokenId": "84686:1154", + "ownerId": "bob.near", + "contractId": "x.paras.near", + "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", + "issuedAt": "2022-01-13T05:56:51.068358", + "copies": 4063, + "metadataId": "x.paras.near:5210047642790498956c9669d6a37b98" + } + ] + } + } +} +``` + + +:::note +In the future, users may be required to register using an api key. For now, simply passing the valueanon for `mb-api-key` will work. +::: + +By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/data/api/tokenbyid) + +```js +import { tokenById } from '@mintbase-js/data' + +const { data, error } = await tokenById('1','rub3n.testnet'); + +if (error) { + console.log('error', error); +} + +console.log(data.tokenData[0]) // => token metadata +``` + + + + +All the examples are using a `Wallet` object, which comes from our basic template: + + \ No newline at end of file diff --git a/docs/7.primitives/nft/interacting/web-app/transfer.md b/docs/7.primitives/nft/interacting/web-app/transfer.md new file mode 100644 index 00000000000..a31e394d05b --- /dev/null +++ b/docs/7.primitives/nft/interacting/web-app/transfer.md @@ -0,0 +1,113 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import {Github} from "@site/src/components/codetabs"; + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "nft.primitives.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_transfer', + args: { + token_id: "1", + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1 +}); +``` + + + + + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "x.paras.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_transfer', + args: { + token_id: "490641", + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1 +}); +``` + + + + + +By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) + +```js +import { Wallet } from './near-wallet'; + +const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; +const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); + +await wallet.callMethod({ + method: 'nft_transfer', + args: { + token_id: "490641", + receiver_id: "bob.near" + }, + contractId: CONTRACT_ADDRESS, + deposit: 1 +}); +``` + +By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/transfer) + +```js +import { useState } from 'react'; +import { useWallet } from '@mintbase-js/react'; +import { execute, transfer, TransferArgs } from '@mintbase-js/sdk'; + +const TransferComponent = ({ tokenId, contractAddress }: TransferArgs): JSX.Element => { + const { selector, activeAccountId } = useWallet(); + + const handleTransfer = async (): Promise => { + const wallet = await selector.wallet(); + + const transferArgs: TransferArgs = { + contractAddress: contractAddress, + transfers: [{ + receiverId: 'mb_carol.testnet', + tokenId: token.tokenId, + }], + } + + await execute( + { wallet }, + transfer(transferArgs), + ); + }; + + return ( +
+ +
+ ); +} +``` + +
+
+ +All the examples are using a `Wallet` object, which comes from our basic template: + + \ No newline at end of file diff --git a/docs/7.primitives/nft/using-nfts.md b/docs/7.primitives/nft/using-nfts.md index 3c2848676e7..98be8522e2d 100644 --- a/docs/7.primitives/nft/using-nfts.md +++ b/docs/7.primitives/nft/using-nfts.md @@ -6,7 +6,30 @@ hide_table_of_contents: false import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import {CodeTabs, Language, Github} from "@site/src/components/codetabs" +import {CodeTabs, Language, Github} from "@site/src/components/codetabs"; + +import BOSMintNFT from "./interacting/bos/mint.md" +import BOSBuyNFT from "./interacting/bos/buy.md" +import BOSQueryNFT from "./interacting/bos/query.md" +import BOSTransferNFT from "./interacting/bos/transfer.md" +import BOSListNFTForSale from "./interacting/bos/list-for-sale.md" + +import WebAppMintNFT from "./interacting/web-app/mint.md" +import WebAppBuyNFT from "./interacting/web-app/buy.md" +import WebAppQueryNFT from "./interacting/web-app/query.md" +import WebAppTransferNFT from "./interacting/web-app/transfer.md" +import WebAppListNFTForSale from "./interacting/web-app/list-for-sale.md" + +import CLIMintNFT from "./interacting/near-cli/mint.md" +import CLIBuyNFT from "./interacting/near-cli/buy.md" +import CLIQueryNFT from "./interacting/near-cli/query.md" +import CLITransferNFT from "./interacting/near-cli/transfer.md" +import CLIListNFTForSale from "./interacting/near-cli/list-for-sale.md" + +import SmartContractMintNFT from "./interacting/smart-contract/mint.md" +import SmartContractBuyNFT from "./interacting/smart-contract/buy.md" +import SmartContractQueryNFT from "./interacting/smart-contract/query.md" +import SmartContractTransferNFT from "./interacting/smart-contract/transfer.md" This section shows how to interact with an NFT smart contract. @@ -16,253 +39,16 @@ This section shows how to interact with an NFT smart contract. - - - - ```js - const tokenData = Near.call( - "nft.primitives.near", - "nft_mint", - { - token_id: "1", - receiver_id: "bob.near", - token_metadata: { - title: "NFT Primitive Token", - description: "Awesome NFT Primitive Token", - media: "string", // URL to associated media, preferably to decentralized, content-addressed storage - } - }, - undefined, - 10000000000000000000000, // Depends on your NFT metadata - ); - ``` - - - - ```js - const tokenData = Near.call( - "x.paras.near", - "nft_mint", - { - token_series_id: "490641", - receiver_id: "bob.near", - }, - undefined, - 10000000000000000000000 // Depends on your NFT metadata - ); - ``` - - In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. - - - - ```js - const tokenData = Near.call( - "thomasettorreiv.mintbase1.near", - "nft_batch_mint", - { - num_to_mint: 1, - owner_id: "bob.near", - metadata: {}, - }, - undefined, - 10000000000000000000000 - ); - ``` - - In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. - - + - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "nft.primitives.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_mint', - args: { - token_id: "1", - receiver_id: "bob.near", - token_metadata: { - title: "NFT Primitive Token", - description: "Awesome NFT Primitive Token", - media: "string", // URL to associated media, preferably to decentralized, content-addressed storage - } - }, - contractId: CONTRACT_ADDRESS, - deposit: 10000000000000000000000 - }); - ``` - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "x.paras.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_mint', - args: { - token_series_id: "490641", - receiver_id: "bob.near", - }, - contractId: CONTRACT_ADDRESS, - deposit: 10000000000000000000000 // Depends on your NFT metadata - }); - ``` - - In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. - - - By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_batch_mint', - args: { - num_to_mint: 1, - owner_id: "bob.near", - metadata: {}, - }, - contractId: CONTRACT_ADDRESS, - deposit: 10000000000000000000000 // Depends on your NFT metadata - }); - ``` - - In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. - - By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/mint) - - ```js - import { useState } from 'react'; - import { useWallet } from '@mintbase-js/react'; - import { execute, mint, MintArgs } from '@mintbase-js/sdk'; - - - export const MintComponent = ({ media, reference, contractAddress, owner }: MintArgs): JSX.Element => { - const { selector } = useWallet(); - - const handleMint = async (): Promise => { - const wallet = await selector.wallet(); - - await execute( - mint({ contractAddress, metadata: { media, reference }, ownerId: owner }) - ); - } - - return ( -
- -
- ); - }; - ``` -
-
- All the examples are using a `Wallet` object, which comes from our basic template: - - +
- - - - ```bash - near call nft.primitives.near nft_mint '{"token_id": "1", "receiver_id": "bob.near", "token_metadata": {"title": "NFT Primitive Token", "description": "Awesome NFT Primitive Token", "media": "string"}}' --depositYocto 10000000000000000000000, --accountId bob.near - ``` - - - - - - ```bash - near call x.paras.near nft_mint '{"token_series_id": "490641", "receiver_id": "bob.near"}' --depositYocto 10000000000000000000000 --accountId bob.near - ``` - - In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series. - - - - - ```bash - near call thomasettorreiv.mintbase1.near nft_batch_mint '{"num_to_mint": 1, "owner_id": "bob.near", "metadata": {}}' --accountId bob.near --depositYocto 10000000000000000000000 - ``` - - In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list. - - + -
- - Minting in Paras - - - In case with Paras NFT contract before minting NFT token you may need to create token series from your contract account. You can do it via [Paras UI](https://paras.id/en) or use `near-cli`: - - ```bash - # Example of the command creating token series on Paras - near call x.paras.near nft_create_series '{"token_metadata": {"title": "NFT #1", "media": "bafybeibnpe5x6euhjtn5qrayfgeemxyru7ho3yhdyaifv7gsvdn46j6vzi", "reference": "bafybeif6cjn5bmdp7w5x2jms2xlz64qmp7crd5z77rl3iy3m54mlustdiu", "copies": 10}, "royalty": {"": 1000}, "price": null}' --accountId --depositYocto 6090000000000000000000 - ``` -
- - ```rust - // Validator interface, for cross-contract calls - #[ext_contract(ext_nft_contract)] - trait ExternalNftContract { - fn nft_mint(&self, token_series_id: String, receiver_id: AccountId) -> Promise; - } - - // Implement the contract structure - #[near_bindgen] - impl Contract { - #[payable] - pub fn nft_mint(&mut self, token_series_id: String, receiver_id: AccountId) -> Promise { - let promise = ext_nft_contract::ext(self.nft_contract.clone()) - .with_static_gas(Gas(30*TGAS)) - .with_attached_deposit(env::attached_deposit()) - .nft_mint(token_series_id, receiver_id); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .with_static_gas(Gas(30*TGAS)) - .nft_mint_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn nft_mint_callback(&self, #[callback_result] call_result: Result) -> Option { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - return None; - } - - // Return the token data - let token_id: TokenId = call_result.unwrap(); - return Some(token_id); - } - } - ``` - - Values of gas and deposit might vary depending on which NFT contract you are calling. +
@@ -272,250 +58,16 @@ This section shows how to interact with an NFT smart contract. - - - - ```js - const tokenData = Near.call( - "x.paras.near", - "nft_buy", - { - token_series_id: "299102", - receiver_id: "bob.near", - }, - undefined, - 205740000000000000000000 // NFT price + storage cost - ); - ``` - - **Example response:** - - ```json - "299102:1" - ``` - - - - ```js - const tokenData = Near.call( - "simple.market.mintbase1.near", - "buy", - { - nft_contract_id: "rubennnnnnnn.mintbase1.near", - token_id: "38", - referrer_id: null, - }, - undefined, - 1000000000000000000000 // NFT price + storage cost (optional, depends on a contract) - ); - ``` - - **Example response:** - - ```json - { - "payout": { - "rub3n.near": "889200000000000000000", - "rubenm4rcus.near": "85800000000000000000" - } - } - ``` - - + - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "x.paras.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_buy', - args: { - token_series_id: "299102", - receiver_id: "bob.near", - }, - contractId: CONTRACT_ADDRESS, - deposit: 205740000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost - }); - ``` - - **Example response:** - - ```json - "299102:1" - ``` - - - By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'buy', - args: { - nft_contract_id: "rubennnnnnnn.mintbase1.near", - token_id: "38" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1000000000000000000000 // attached deposit in yoctoNEAR, covers NFT price + storage cost (optional) - }); - ``` - - **Example response:** - - ```json - { - "payout": { - "rub3n.near": "889200000000000000000", - "rubenm4rcus.near": "85800000000000000000" - } - } - ``` - - By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/buy) - - ```js - import { useState } from 'react'; - import { useWallet } from '@mintbase-js/react'; - import { execute, burn, BuyArgs } from '@mintbase-js/sdk'; - - export const BuyComponent = ({ contractAddress, price, tokenId, affiliateAccount, marketId }: BuyArgs): JSX.Element => { - const { selector } = useWallet(); - - const handleBuy = async (): Promise => { - const wallet = await selector.wallet(); - - const buyArgs = { - contractAddress, - tokenId, - affiliateAccount, - marketId, - price, - } - - await execute( - { wallet }, - buy(buyArgs) - ); - - } - - return ( -
- -
- ); - }; - ``` -
-
- All the examples are using a `Wallet` object, which comes from our basic template: - - +
- - - - ```bash - near call x.paras.near buy '{"token_series_id": "299102", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.20574 - ``` - - **Example response:** - - ```json - "299102:1" - ``` - - - - ```bash - near call simple.market.mintbase1.near buy '{"nft_contract_id": "rubennnnnnnn.mintbase1.near", "token_id": "38"}' --accountId bob.near --deposit 0.001 - ``` - - **Example response:** - - ```json - { - "payout": { - "rub3n.near": "889200000000000000000", - "rubenm4rcus.near": "85800000000000000000" - } - } - ``` - - - + - This is an example on how you can make your smart contract buy a NFT on some marketplace (Paras this case). - - Please note that in this example the contract will be the owner of the NFT, however, some marketplaces allow you to buy NFT for somebody else. - - ```rust - const NFT_MARKETPLACE_CONTRACT: &str = "paras-marketplace-v2.testnet"; - - // Define the contract structure - #[near_bindgen] - #[derive(BorshDeserialize, BorshSerialize)] - pub struct Contract { - nft_marketplace_contract: AccountId - } - - impl Default for Contract { - // The default trait with which to initialize the contract - fn default() -> Self { - Self { - nft_marketplace_contract: NFT_MARKETPLACE_CONTRACT.parse().unwrap() - } - } - } - - // Validator interface, for cross-contract calls - #[ext_contract(ext_nft_contract)] - trait ExternalNftContract { - fn buy(&self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise; - } - - // Implement the contract structure - #[near_bindgen] - impl Contract { - #[payable] - pub fn buy(&mut self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option, price: Option) -> Promise { - let promise = ext_nft_contract::ext(self.nft_marketplace_contract.clone()) - .with_static_gas(Gas(30*TGAS)) - .with_attached_deposit(env::attached_deposit()) - .buy(nft_contract_id, token_id, ft_token_id, price); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .with_static_gas(Gas(30*TGAS)) - .buy_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn buy_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - } - } - } - ``` +
@@ -525,683 +77,16 @@ This section shows how to interact with an NFT smart contract. - - - - ```js - const tokenData = Near.view("nft.primitives.near", "nft_token", { - token_id: "1", - }); - ``` - - **Example response:** - - ```json - { - "token_id": "1", - "owner_id": "bob.near", - "metadata": { - "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - "description": "string", // free-form description - "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage - "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - "copies": 1, // number of copies of this set of metadata in existence when token was minted. - "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds - "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds - "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds - "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds - "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. - "reference": "string", // URL to an off-chain JSON file with more info. - "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. - } - } - ``` - - - By calling a Paras smart contract method - - ```js - const tokenData = Near.view("x.paras.near", "nft_token", { - token_id: "84686:1154", - }); - ``` - - **Example response:** - - ```json - { - "token_id": "84686:1154", - "owner_id": "bob.near", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": null, - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": "1642053411068358156", - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null - }, - "approved_account_ids": {} - } - ``` - - By calling a Paras API method - - ```js - const tokenData = fetch("https://api-v2-mainnet.paras.id/token?token_id=84686:1154"); - ``` - - **Example response:** - - ```json - { - "status": 1, - "data": { - "results": [ - { - "_id": "61dfbf27284abc1cc0b87c9d", - "contract_id": "x.paras.near", - "token_id": "84686:1154", - "owner_id": "bob.near", - "token_series_id": "84686", - "edition_id": "1154", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": "Holding this silver coin in your wallet will bring you health and happiness \uD83D\uDE0A", - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null, - "collection": "Tokenfox Collection Cards", - "collection_id": "tokenfox-collection-cards-by-tokenfoxnear", - "creator_id": "tokenfox.near", - "blurhash": "U7F~gc00_3D%00~q4n%M_39F-;RjM{xuWBRj", - "score": 0, - "mime_type": "image/png" - }, - "royalty": { - "tokenfox.near": 1000 - }, - "price": null, - "approval_id": null, - "ft_token_id": null, - "has_price": null, - "is_creator": true, - "total_likes": 8, - "likes": null, - "categories": [], - "view": 4 - } - ], - "count": 1, - "skip": 0, - "limit": 10 - } - } - ``` - - See the [Paras API documentation](https://parashq.github.io/) for the full list of methods. - - When you call Paras smart contract method it returns data that are stored in the Paras NFT smart contract. It means a response contains only data about NFTs which were minted via Paras NFT contract. - - When you call Paras API methods it returns data from other NFT contracts as well, due to the work of the indexer. It means you might want to pass more parameters like `contract_id` or `owner_id` to make the response more accurate. - - - By calling a Mintbase smart contract method - - ```js - const tokenData = Near.view("anthropocene.mintbase1.near", "nft_token", { - token_id: "17960", - }); - ``` - - **Example response:** - - ```json - { - "token_id": "17960", - "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", - "approved_account_ids": {}, - "metadata": { - "title": null, - "description": null, - "media": null, - "media_hash": null, - "copies": 1, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", - "reference_hash": null - }, - "royalty": { - "split_between": { - "seventhage.near": { - "numerator": 10000 - } - }, - "percentage": { - "numerator": 100 - } - }, - "split_owners": null, - "minter": "anthropocene.seventhage.near", - "loan": null, - "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, - "origin_key": null - } - ``` - - When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. - - By calling a Mintbase GraphQL API method - - ```js - const tokenData = fetch("https://graph.mintbase.xyz", { - method: "POST", - headers: { - "mb-api-key": "anon", - "Content-Type": "application/json", - "x-hasura-role": "anonymous", - }, - body: JSON.stringify({ - query: ` - query getToken{ - tokens: nft_tokens( - where: { - token_id: { _eq: "84686:1154" } - } - ) { - tokenId: token_id - ownerId: owner - contractId: nft_contract_id - reference - issuedAt: issued_at - copies - metadataId: metadata_id - } - } - `, - }), - }); - ``` - - **Example response:** - - ```json - { - "ok": true, - "status": 200, - "contentType": "application/json", - "body": { - "data": { - "tokens": [ - { - "tokenId": "84686:1154", - "ownerId": "bob.near", - "contractId": "x.paras.near", - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "issuedAt": "2022-01-13T05:56:51.068358", - "copies": 4063, - "metadataId": "x.paras.near:5210047642790498956c9669d6a37b98" - } - ] - } - } - } - ``` - - In the future, users may be required to register using an api key. For now, simply passing the valueanon for `mb-api-key` will work. - - + - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "nft.primitives.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - const response = await wallet.viewMethod({ - method: 'nft_token', - args: { - token_id: "1" - } - }); - ``` - - **Example response:** - - ```json - { - "token_id": "1", - "owner_id": "bob.near", - "metadata": { - "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - "description": "string", // free-form description - "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage - "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - "copies": 1, // number of copies of this set of metadata in existence when token was minted. - "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds - "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds - "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds - "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds - "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. - "reference": "string", // URL to an off-chain JSON file with more info. - "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. - } - } - ``` - - - By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "x.paras.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - const response = await wallet.viewMethod({ - method: 'nft_token', - args: { - token_id: "84686:1154" - } - }); - ``` - - **Example response:** - - ```json - { - "token_id": "84686:1154", - "owner_id": "bob.near", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": null, - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": "1642053411068358156", - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null - }, - "approved_account_ids": {} - } - ``` - - By calling a Paras API method - - ```js - const tokenData = fetch("https://api-v2-mainnet.paras.id/token?token_id=84686:1154"); - ``` - - **Example response:** - - ```json - { - "status": 1, - "data": { - "results": [ - { - "_id": "61dfbf27284abc1cc0b87c9d", - "contract_id": "x.paras.near", - "token_id": "84686:1154", - "owner_id": "bob.near", - "token_series_id": "84686", - "edition_id": "1154", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": "Holding this silver coin in your wallet will bring you health and happiness \uD83D\uDE0A", - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null, - "collection": "Tokenfox Collection Cards", - "collection_id": "tokenfox-collection-cards-by-tokenfoxnear", - "creator_id": "tokenfox.near", - "blurhash": "U7F~gc00_3D%00~q4n%M_39F-;RjM{xuWBRj", - "score": 0, - "mime_type": "image/png" - }, - "royalty": { - "tokenfox.near": 1000 - }, - "price": null, - "approval_id": null, - "ft_token_id": null, - "has_price": null, - "is_creator": true, - "total_likes": 8, - "likes": null, - "categories": [], - "view": 4 - } - ], - "count": 1, - "skip": 0, - "limit": 10 - } - } - ``` - - See the [Paras API documentation](https://parashq.github.io/) for the full list of methods. - - When you call Paras smart contract method it returns data that are stored in the Paras NFT smart contract. It means a response contains only data about NFTs which were minted via Paras NFT contract. - - When you call Paras API methods it returns data from other NFT contracts as well, due to the work of the indexer. It means you might want to pass more parameters like `contract_id` or `owner_id` to make the response more accurate. - - - By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "anthropocene.mintbase1.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - const response = await wallet.viewMethod({ - method: 'nft_token', - args: { - token_id: "17960" - } - }); - ``` - - **Example response:** - - ```json - { - "token_id": "17960", - "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", - "approved_account_ids": {}, - "metadata": { - "title": null, - "description": null, - "media": null, - "media_hash": null, - "copies": 1, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", - "reference_hash": null - }, - "royalty": { - "split_between": { - "seventhage.near": { - "numerator": 10000 - } - }, - "percentage": { - "numerator": 100 - } - }, - "split_owners": null, - "minter": "anthropocene.seventhage.near", - "loan": null, - "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, - "origin_key": null - } - ``` - - When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. - - By calling a Mintbase GraphQL API method - - ```js - const tokenData = fetch("https://graph.mintbase.xyz", { - method: "POST", - headers: { - "mb-api-key": "anon", - "Content-Type": "application/json", - "x-hasura-role": "anonymous", - }, - body: JSON.stringify({ - query: ` - query getToken{ - tokens: nft_tokens( - where: { - token_id: { _eq: "84686:1154" } - } - ) { - tokenId: token_id - ownerId: owner - contractId: nft_contract_id - reference - issuedAt: issued_at - copies - metadataId: metadata_id - } - } - `, - }), - }); - ``` - - **Example response:** - - ```json - { - "ok": true, - "status": 200, - "contentType": "application/json", - "body": { - "data": { - "tokens": [ - { - "tokenId": "84686:1154", - "ownerId": "bob.near", - "contractId": "x.paras.near", - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "issuedAt": "2022-01-13T05:56:51.068358", - "copies": 4063, - "metadataId": "x.paras.near:5210047642790498956c9669d6a37b98" - } - ] - } - } - } - ``` - - In the future, users may be required to register using an api key. For now, simply passing the valueanon for `mb-api-key` will work. - - By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/data/api/tokenbyid) - - ```js - import { tokenById } from '@mintbase-js/data' - - const { data, error } = await tokenById('1','rub3n.testnet'); - - if (error) { - console.log(error); - } - - console.log(data.tokenData[0]) // => token metadata - ``` - - - - All the examples are using a `Wallet` object, which comes from our basic template: - - + - - - - ```bash - near view nft.primitives.near nft_token '{"token_id": "1"}' - ``` - - **Example response:** - - ```json - { - "token_id": "1", - "owner_id": "bob.near", - "metadata": { - "title": "string", // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055" - "description": "string", // free-form description - "media": "string", // URL to associated media, preferably to decentralized, content-addressed storage - "media_hash": "string", // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included. - "copies": 1, // number of copies of this set of metadata in existence when token was minted. - "issued_at": 1642053411068358156, // When token was issued or minted, Unix epoch in milliseconds - "expires_at": 1642053411168358156, // When token expires, Unix epoch in milliseconds - "starts_at": 1642053411068358156, // When token starts being valid, Unix epoch in milliseconds - "updated_at": 1642053411068358156, // When token was last updated, Unix epoch in milliseconds - "extra": "string", // anything extra the NFT wants to store on-chain. Can be stringified JSON. - "reference": "string", // URL to an off-chain JSON file with more info. - "reference_hash": "string" // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included. - } - } - ``` - - - - ```bash - near view x.paras.near nft_token '{"token_id": "84686:1154"}' - ``` - - **Example response:** - - ```json - { - "token_id": "84686:1154", - "owner_id": "bob.near", - "metadata": { - "title": "Tokenfox Silver Coin #1154", - "description": null, - "media": "bafkreihpapfu7rzsmejjgl2twllge6pbrfmqaahj2wkz6nq55c6trhhtrq", - "media_hash": null, - "copies": 4063, - "issued_at": "1642053411068358156", - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "bafkreib6uj5kxbadfvf6qes5flema7jx6u5dj5zyqcneaoyqqzlm6kpu5a", - "reference_hash": null - }, - "approved_account_ids": {} - } - ``` - - - - ```bash - near view anthropocene.mintbase1.near nft_token '{"token_id": "17960"}' - ``` - - **Example response:** - - ```json - { - "token_id": "17960", - "owner_id": "876f40299dd919f39252863e2136c4e1922cd5f78759215474cbc8f1fc361e14", - "approved_account_ids": {}, - "metadata": { - "title": null, - "description": null, - "media": null, - "media_hash": null, - "copies": 1, - "issued_at": null, - "expires_at": null, - "starts_at": null, - "updated_at": null, - "extra": null, - "reference": "F-30s_uQ3ZdAHZClY4DYatDPapaIRNLju41RxfMXC24", - "reference_hash": null - }, - "royalty": { - "split_between": { - "seventhage.near": { - "numerator": 10000 - } - }, - "percentage": { - "numerator": 100 - } - }, - "split_owners": null, - "minter": "anthropocene.seventhage.near", - "loan": null, - "composeable_stats": { "local_depth": 0, "cross_contract_children": 0 }, - "origin_key": null - } - ``` - - When someone creates a NFT on Mintbase they need to deploy their own NFT contract using Mintbase factory. Those smart contract are subaccounts of mintbase1.near, e.g. `anthropocene.mintbase1.near`. - - + - - ```rust - // Validator interface, for cross-contract calls - #[ext_contract(ext_nft_contract)] - trait ExternalNftContract { - fn nft_token(&self, token_id: TokenId) -> Promise; - } - - // Implement the contract structure - #[near_bindgen] - impl Contract { - pub fn nft_token(&self, token_id: TokenId) -> Promise { - let promise = ext_nft_contract::ext(self.nft_contract.clone()) - .nft_token(token_id); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .nft_token_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn nft_token_callback(&self, #[callback_result] call_result: Result) -> Option { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - return None; - } - - // Return the token data - let token_data: Token = call_result.unwrap(); - return Some(token_data); - } - } - ``` + @@ -1211,212 +96,16 @@ This section shows how to interact with an NFT smart contract. - - - - ```js - const tokenData = Near.call( - "nft.primitives.near", - "nft_transfer", - { - token_id: "1", - receiver_id: "bob.near" - }, - undefined, - 1, - ); - ``` - - - - ```js - const tokenData = Near.call( - "x.paras.near", - "nft_transfer", - { - token_id: "490641", - receiver_id: "bob.near" - }, - undefined, - 1 - ); - ``` - - - - ```js - const tokenData = Near.call( - "thomasettorreiv.mintbase1.near", - "nft_transfer", - { - token_id: "490641", - receiver_id: "bob.near" - }, - undefined, - 1 - ); - ``` - - + - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "nft.primitives.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_transfer', - args: { - token_id: "1", - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1 - }); - ``` - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "x.paras.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_transfer', - args: { - token_id: "490641", - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1 - }); - ``` - - - By using [`near-api-js`](https://docs.near.org/tools/near-api-js/quick-reference) - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "thomasettorreiv.mintbase1.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'nft_transfer', - args: { - token_id: "490641", - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - deposit: 1 - }); - ``` - - By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/transfer) - - ```js - import { useState } from 'react'; - import { useWallet } from '@mintbase-js/react'; - import { execute, transfer, TransferArgs } from '@mintbase-js/sdk'; - - const TransferComponent = ({ tokenId, contractAddress }: TransferArgs): JSX.Element => { - const { selector, activeAccountId } = useWallet(); - - const handleTransfer = async (): Promise => { - const wallet = await selector.wallet(); - - const transferArgs: TransferArgs = { - contractAddress: contractAddress, - transfers: [{ - receiverId: 'mb_carol.testnet', - tokenId: token.tokenId, - }], - } - - await execute( - { wallet }, - transfer(transferArgs), - ); - }; - - return ( -
- -
- ); - } - ``` -
-
- All the examples are using a `Wallet` object, which comes from our basic template: - - +
- - - - ```bash - near call nft.primitives.near nft_transfer '{"token_id": "1", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 - ``` - - - ```bash - near call x.paras.near nft_transfer '{"token_id": "490641", "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 - ``` - - - ```bash - near call thomasettorreiv.mintbase1.near nft_transfer '{"token_id": "490641" "receiver_id": "bob.near"}' --accountId bob.near --deposit 0.000000000000000000000001 - ``` - - + - Please notice that a contract can only transfer an NFT that they own, or an NFT that they were approved to transfer. - - ```rust - const YOCTO_NEAR: u128 = 1; - - #[ext_contract(ext_nft_contract)] - trait ExternalNftContract { - fn nft_transfer(&self, receiver_id: AccountId, token_id: TokenId) -> Promise; - } - - impl Contract { - #[payable] - pub fn nft_transfer(&mut self, receiver_id: AccountId, token_id: TokenId) -> Promise { - let promise = ext_nft_contract::ext(self.nft_contract.clone()) - .with_attached_deposit(YOCTO_NEAR) - .nft_transfer(receiver_id, token_id); - - return promise.then( // Create a promise to callback query_greeting_callback - Self::ext(env::current_account_id()) - .nft_transfer_callback() - ) - } - - #[private] // Public - but only callable by env::current_account_id() - pub fn nft_transfer_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) { - // Check if the promise succeeded - if call_result.is_err() { - log!("There was an error contacting NFT contract"); - } - } - } - ``` - +
@@ -1435,203 +124,12 @@ In order to put a NFT for a sale on a marketplace you need to do two actions: - - - - ```js - Near.call( - "marketplace.paras.near", - "storage_deposit", - { - receiver_id: "bob.near" - }, - undefined, - 9390000000000000000 - ); - - Near.call( - "nft.primitives.near", - "nft_approve", - { - token_id: "1e95238d266e5497d735eb30", - account_id: "marketplace.paras.near", - msg: { - price: "200000000000000000000000", - market_type: "sale", - ft_token_id: "near" - } - } - ); - ``` - - The method `nft_approve` will call `nft_on_approve` in `marketplace.paras.near`. - - - - ```js - Near.call( - "simple.market.mintbase1.near", - "deposit_storage", - { - autotransfer: true - }, - undefined, - 9390000000000000000 - ); - - Near.call( - "nft.primitives.near", - "nft_approve", - { - token_id: "3c46b76cbd48e65f2fc88473", - account_id: "simple.market.mintbase1.near", - msg: { - price: "200000000000000000000000" - } - } - ); - ``` - - The method `nft_approve` will call `nft_on_approve` in `simple.market.mintbase1.near`. - - + - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "marketplace.paras.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'storage_deposit', - args: { - receiver_id: "bob.near" - }, - contractId: CONTRACT_ADDRESS, - gas: 300000000000000, // attached GAS (optional) - deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) - }); - - await wallet.callMethod({ - method: 'nft_approve', - args: { - token_id: "1e95238d266e5497d735eb30", - account_id: "marketplace.paras.near", - msg: { - price: "200000000000000000000000", - market_type: "sale", - ft_token_id: "near" - } - }, - contractId: "nft.primitives.near" - }); - ``` - - Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. - - - - ```js - import { Wallet } from './near-wallet'; - - const CONTRACT_ADDRESS = "simple.market.mintbase1.near"; - const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS }); - - await wallet.callMethod({ - method: 'deposit_storage', - args: { - autotransfer: true - }, - contractId: CONTRACT_ADDRESS, - gas: 300000000000000, // attached GAS (optional) - deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional) - }); - - await wallet.callMethod({ - method: 'nft_approve', - args: { - args: { - token_id: "3c46b76cbd48e65f2fc88473", - account_id: "simple.market.mintbase1.near", - msg: { - price: "200000000000000000000000" - } - }, - }, - contractId: "nft.primitives.near" - }); - ``` - - Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. - - By using [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/list) - - ```js - import { useState } from 'react'; - import { useWallet } from '@mintbase-js/react'; - import { execute, list, ListArgs } from '@mintbase-js/sdk'; - - export const ListComponent = ({ contractAddress, marketAddress , tokenId, price }: ListArgs): JSX.Element => { - - const { selector } = useWallet(); - - const handleList = async (): Promise => { - const wallet = await selector.wallet(); - - await execute( - { wallet }, - list({ - contractAddress: nftContractId, - marketAddress: marketId, - tokenId: tokenId, - price: price - }) - ) - } - - return ( -
- -
- ); - }; - ``` -
-
- All the examples are using a `Wallet` object, which comes from our basic template: - - +
- - - - ```bash - near call marketplace.paras.near storage_deposit '{"receiver_id": "bob.near"}' --accountId bob.near --deposit 0.00939 - - near call nft.primitives.near nft_approve '{"token_id": "1e95238d266e5497d735eb30", "account_id": "marketplace.paras.near", "msg": {"price": "200000000000000000000000", "market_type": "sale", "ft_token_id": "near"}}' --accountId bob.near - ``` - - Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback. - - - - ```bash - near call simple.market.mintbase1.near deposit_storage '{"autotransfer": "true"}' --accountId bob.near --deposit 0.00939 - - near call nft.primitives.near nft_approve '{"token_id": "3c46b76cbd48e65f2fc88473", "account_id": "simple.market.mintbase1.near", "msg": {"price": "200000000000000000000000"}}' --accountId bob.near - ``` - - Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback. - - +
diff --git a/website/sidebars.js b/website/sidebars.js index 2b98ec24f46..c284c968dc1 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -367,14 +367,6 @@ const sidebar = { }, "primitives/nft/introduction", "primitives/nft/using-nfts", - { - "Using NFTs": [ - "primitives/nft/interacting/bos", - "primitives/nft/interacting/web-app", - "primitives/nft/interacting/smart-contract", - "primitives/nft/interacting/near-cli" - ] - }, "primitives/nft/additional-resources", { "type": "html", From df1e402556404737904d331fd31d0e9aed30838f Mon Sep 17 00:00:00 2001 From: garikbesson Date: Tue, 23 Jan 2024 11:10:04 +0300 Subject: [PATCH 4/5] remove unused code --- docs/7.primitives/nft/using-nfts.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/7.primitives/nft/using-nfts.md b/docs/7.primitives/nft/using-nfts.md index 98be8522e2d..4c8e1770050 100644 --- a/docs/7.primitives/nft/using-nfts.md +++ b/docs/7.primitives/nft/using-nfts.md @@ -6,7 +6,6 @@ hide_table_of_contents: false import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import {CodeTabs, Language, Github} from "@site/src/components/codetabs"; import BOSMintNFT from "./interacting/bos/mint.md" import BOSBuyNFT from "./interacting/bos/buy.md" @@ -31,8 +30,6 @@ import SmartContractBuyNFT from "./interacting/smart-contract/buy.md" import SmartContractQueryNFT from "./interacting/smart-contract/query.md" import SmartContractTransferNFT from "./interacting/smart-contract/transfer.md" -This section shows how to interact with an NFT smart contract. - --- ## Mint a NFT From ae2434a62d3943168265bfe221e3a24168538c66 Mon Sep 17 00:00:00 2001 From: gagdiez Date: Tue, 23 Jan 2024 16:48:53 +0100 Subject: [PATCH 5/5] css hack --- docs/7.primitives/nft/interacting/bos/buy.md | 2 +- docs/7.primitives/nft/interacting/bos/list-for-sale.md | 2 +- docs/7.primitives/nft/interacting/bos/mint.md | 2 +- docs/7.primitives/nft/interacting/bos/query.md | 2 +- docs/7.primitives/nft/interacting/bos/transfer.md | 2 +- docs/7.primitives/nft/interacting/near-cli/buy.md | 2 +- docs/7.primitives/nft/interacting/near-cli/list-for-sale.md | 2 +- docs/7.primitives/nft/interacting/near-cli/mint.md | 2 +- docs/7.primitives/nft/interacting/near-cli/query.md | 2 +- docs/7.primitives/nft/interacting/near-cli/transfer.md | 2 +- docs/7.primitives/nft/interacting/web-app/buy.md | 2 +- docs/7.primitives/nft/interacting/web-app/list-for-sale.md | 2 +- docs/7.primitives/nft/interacting/web-app/mint.md | 2 +- docs/7.primitives/nft/interacting/web-app/query.md | 2 +- docs/7.primitives/nft/interacting/web-app/transfer.md | 2 +- docs/7.primitives/nft/using-nfts.md | 2 ++ 16 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/7.primitives/nft/interacting/bos/buy.md b/docs/7.primitives/nft/interacting/bos/buy.md index a35f9122efb..4d419bdea5f 100644 --- a/docs/7.primitives/nft/interacting/bos/buy.md +++ b/docs/7.primitives/nft/interacting/bos/buy.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```js diff --git a/docs/7.primitives/nft/interacting/bos/list-for-sale.md b/docs/7.primitives/nft/interacting/bos/list-for-sale.md index 3c3541b38be..9fe5682f5e4 100644 --- a/docs/7.primitives/nft/interacting/bos/list-for-sale.md +++ b/docs/7.primitives/nft/interacting/bos/list-for-sale.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```js diff --git a/docs/7.primitives/nft/interacting/bos/mint.md b/docs/7.primitives/nft/interacting/bos/mint.md index a07b2b85af7..62bf5f353ad 100644 --- a/docs/7.primitives/nft/interacting/bos/mint.md +++ b/docs/7.primitives/nft/interacting/bos/mint.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```js diff --git a/docs/7.primitives/nft/interacting/bos/query.md b/docs/7.primitives/nft/interacting/bos/query.md index 6e866efea0f..967a3faa858 100644 --- a/docs/7.primitives/nft/interacting/bos/query.md +++ b/docs/7.primitives/nft/interacting/bos/query.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```js diff --git a/docs/7.primitives/nft/interacting/bos/transfer.md b/docs/7.primitives/nft/interacting/bos/transfer.md index 6a00df37d7a..70ed73eda7a 100644 --- a/docs/7.primitives/nft/interacting/bos/transfer.md +++ b/docs/7.primitives/nft/interacting/bos/transfer.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```js diff --git a/docs/7.primitives/nft/interacting/near-cli/buy.md b/docs/7.primitives/nft/interacting/near-cli/buy.md index 27afd9300b3..46859f374c6 100644 --- a/docs/7.primitives/nft/interacting/near-cli/buy.md +++ b/docs/7.primitives/nft/interacting/near-cli/buy.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```bash diff --git a/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md b/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md index 36cc5c8f494..92648cc3771 100644 --- a/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md +++ b/docs/7.primitives/nft/interacting/near-cli/list-for-sale.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```bash diff --git a/docs/7.primitives/nft/interacting/near-cli/mint.md b/docs/7.primitives/nft/interacting/near-cli/mint.md index d58b34056d1..ee6918d8347 100644 --- a/docs/7.primitives/nft/interacting/near-cli/mint.md +++ b/docs/7.primitives/nft/interacting/near-cli/mint.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```bash diff --git a/docs/7.primitives/nft/interacting/near-cli/query.md b/docs/7.primitives/nft/interacting/near-cli/query.md index 38de189a035..2fd7ab38f22 100644 --- a/docs/7.primitives/nft/interacting/near-cli/query.md +++ b/docs/7.primitives/nft/interacting/near-cli/query.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```bash diff --git a/docs/7.primitives/nft/interacting/near-cli/transfer.md b/docs/7.primitives/nft/interacting/near-cli/transfer.md index b4ef6ce60c2..e42f21dd6b5 100644 --- a/docs/7.primitives/nft/interacting/near-cli/transfer.md +++ b/docs/7.primitives/nft/interacting/near-cli/transfer.md @@ -1,7 +1,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - + ```bash diff --git a/docs/7.primitives/nft/interacting/web-app/buy.md b/docs/7.primitives/nft/interacting/web-app/buy.md index e6486fb52f2..40f49403db5 100644 --- a/docs/7.primitives/nft/interacting/web-app/buy.md +++ b/docs/7.primitives/nft/interacting/web-app/buy.md @@ -2,7 +2,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import {Github} from "@site/src/components/codetabs"; - + ```js diff --git a/docs/7.primitives/nft/interacting/web-app/list-for-sale.md b/docs/7.primitives/nft/interacting/web-app/list-for-sale.md index 941f0ad18e5..f4d8a581d5b 100644 --- a/docs/7.primitives/nft/interacting/web-app/list-for-sale.md +++ b/docs/7.primitives/nft/interacting/web-app/list-for-sale.md @@ -2,7 +2,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import {Github} from "@site/src/components/codetabs"; - + ```js diff --git a/docs/7.primitives/nft/interacting/web-app/mint.md b/docs/7.primitives/nft/interacting/web-app/mint.md index 2397f3c6781..16097333a56 100644 --- a/docs/7.primitives/nft/interacting/web-app/mint.md +++ b/docs/7.primitives/nft/interacting/web-app/mint.md @@ -2,7 +2,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import {CodeTabs, Github} from "@site/src/components/codetabs"; - + ```js diff --git a/docs/7.primitives/nft/interacting/web-app/query.md b/docs/7.primitives/nft/interacting/web-app/query.md index dff303acb1b..c2bdf99e0d5 100644 --- a/docs/7.primitives/nft/interacting/web-app/query.md +++ b/docs/7.primitives/nft/interacting/web-app/query.md @@ -2,7 +2,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import {Github} from "@site/src/components/codetabs"; - + ```js diff --git a/docs/7.primitives/nft/interacting/web-app/transfer.md b/docs/7.primitives/nft/interacting/web-app/transfer.md index a31e394d05b..264a80669f0 100644 --- a/docs/7.primitives/nft/interacting/web-app/transfer.md +++ b/docs/7.primitives/nft/interacting/web-app/transfer.md @@ -2,7 +2,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import {Github} from "@site/src/components/codetabs"; - + ```js diff --git a/docs/7.primitives/nft/using-nfts.md b/docs/7.primitives/nft/using-nfts.md index 4c8e1770050..60d3d4a9f1e 100644 --- a/docs/7.primitives/nft/using-nfts.md +++ b/docs/7.primitives/nft/using-nfts.md @@ -30,6 +30,8 @@ import SmartContractBuyNFT from "./interacting/smart-contract/buy.md" import SmartContractQueryNFT from "./interacting/smart-contract/query.md" import SmartContractTransferNFT from "./interacting/smart-contract/transfer.md" +This section shows how to interact with an NFT smart contract from different tools. Please choose which tool you are planing to use. + --- ## Mint a NFT