From 9ac893298f153fbdf1ae320fcc8561bcb267feb3 Mon Sep 17 00:00:00 2001 From: Hiep Immutable <118787287+hiep-immutable@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:41:05 +1000 Subject: [PATCH] GMS-2160 Add minting API code examples (#2190) --- ...eate-erc1155-mint-request-with-metadata.ts | 52 ++++++++++++ .../create-erc1155-mint-request.ts | 26 ++++++ ...721-mint-quantity-request-with-metadata.ts | 78 ++++++++++++++++++ .../create-erc721-mint-quantity-request.ts | 22 +++++ ...reate-erc721-mint-request-with-metadata.ts | 81 +++++++++++++++++++ .../create-erc721-mint-request.ts | 24 ++++++ .../get-mint-request.ts | 10 +++ .../list-mint-requests.ts | 9 +++ examples/minting/README.md | 1 - 9 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request-with-metadata.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request-with-metadata.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request-with-metadata.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/get-mint-request.ts create mode 100644 examples/blockchain-data/minting-api-examples-with-node/list-mint-requests.ts delete mode 100644 examples/minting/README.md diff --git a/examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request-with-metadata.ts b/examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request-with-metadata.ts new file mode 100644 index 0000000000..812dc95e5e --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request-with-metadata.ts @@ -0,0 +1,52 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function createMintRequestWithTokenIdAndMetadataAndAmount( + chainName: string, + contractAddress: string, + owner_address: string, + reference_id: string, + token_id: string, + amount: string +): Promise { + return await client.createMintRequest({ + chainName, + contractAddress, + createMintRequestRequest: { + assets: [ + { + owner_address, + reference_id, + token_id, + amount, + metadata: { + name: "Brown Dog Red Car", + description: "This SFT is a Brown Dog in a Red Car", + image: "https://mt-test-2.s3.ap-southeast-2.amazonaws.com/BDRC.png", + external_url: null, + animation_url: null, + youtube_url: null, + attributes: [ + { + trait_type: "Pet", + value: "Dog", + }, + { + trait_type: "Pet Colour", + value: "Brown", + }, + { + trait_type: "Vehicle", + value: "Car", + }, + { + trait_type: "Vehicle Colour", + value: "Red", + }, + ], + }, + }, + ], + }, + }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request.ts b/examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request.ts new file mode 100644 index 0000000000..78333e3965 --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/create-erc1155-mint-request.ts @@ -0,0 +1,26 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function createMintRequestWithTokenIdAndMetadataAndAmount( + chainName: string, + contractAddress: string, + owner_address: string, + reference_id: string, + token_id: string, + amount: string +): Promise { + return await client.createMintRequest({ + chainName, + contractAddress, + createMintRequestRequest: { + assets: [ + { + owner_address, + reference_id, + token_id, + amount, + }, + ], + }, + }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request-with-metadata.ts b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request-with-metadata.ts new file mode 100644 index 0000000000..7835e1044d --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request-with-metadata.ts @@ -0,0 +1,78 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function createMintRequestWithMetadata( + chainName: string, + contractAddress: string, + owner_address: string, + reference_id: string +): Promise { + return await client.createMintRequest({ + chainName, + contractAddress, + createMintRequestRequest: { + assets: [ + { + owner_address, + reference_id, + metadata: { + name: "Brown Dog Green Car", + description: "This NFT is a Brown Dog in a Green Car", + image: "https://mt-test-2.s3.ap-southeast-2.amazonaws.com/BDGC.png", + external_url: null, + animation_url: null, + youtube_url: null, + attributes: [ + { + trait_type: "Pet", + value: "Dog", + }, + { + trait_type: "Pet Colour", + value: "Brown", + }, + { + trait_type: "Vehicle", + value: "Car", + }, + { + trait_type: "Vehicle Colour", + value: "Green", + }, + ], + }, + }, + { + owner_address, + reference_id, + metadata: { + name: "Brown Dog Red Car", + description: "This NFT is a Brown Dog in a Red Car", + image: "https://mt-test-2.s3.ap-southeast-2.amazonaws.com/BDRC.png", + external_url: null, + animation_url: null, + youtube_url: null, + attributes: [ + { + trait_type: "Pet", + value: "Dog", + }, + { + trait_type: "Pet Colour", + value: "Brown", + }, + { + trait_type: "Vehicle", + value: "Car", + }, + { + trait_type: "Vehicle Colour", + value: "Red", + }, + ], + }, + }, + ], + }, + }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request.ts b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request.ts new file mode 100644 index 0000000000..4ffef08ec5 --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-quantity-request.ts @@ -0,0 +1,22 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function createMintRequest( + chainName: string, + contractAddress: string, + owner_address: string, + reference_id: string +): Promise { + return await client.createMintRequest({ + chainName, + contractAddress, + createMintRequestRequest: { + assets: [ + { + owner_address, + reference_id, + }, + ], + }, + }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request-with-metadata.ts b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request-with-metadata.ts new file mode 100644 index 0000000000..86367a56d8 --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request-with-metadata.ts @@ -0,0 +1,81 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function createMintRequestWithTokenIdAndMetadata( + chainName: string, + contractAddress: string, + owner_address: string, + reference_id: string, + token_id: string +): Promise { + return await client.createMintRequest({ + chainName, + contractAddress, + createMintRequestRequest: { + assets: [ + { + owner_address, + reference_id, + token_id, + metadata: { + name: "Brown Dog Green Car", + description: "This NFT is a Brown Dog in a Green Car", + image: "https://mt-test-2.s3.ap-southeast-2.amazonaws.com/BDGC.png", + external_url: null, + animation_url: null, + youtube_url: null, + attributes: [ + { + trait_type: "Pet", + value: "Dog", + }, + { + trait_type: "Pet Colour", + value: "Brown", + }, + { + trait_type: "Vehicle", + value: "Car", + }, + { + trait_type: "Vehicle Colour", + value: "Green", + }, + ], + }, + }, + { + owner_address, + reference_id, + token_id, + metadata: { + name: "Brown Dog Red Car", + description: "This NFT is a Brown Dog in a Red Car", + image: "https://mt-test-2.s3.ap-southeast-2.amazonaws.com/BDRC.png", + external_url: null, + animation_url: null, + youtube_url: null, + attributes: [ + { + trait_type: "Pet", + value: "Dog", + }, + { + trait_type: "Pet Colour", + value: "Brown", + }, + { + trait_type: "Vehicle", + value: "Car", + }, + { + trait_type: "Vehicle Colour", + value: "Red", + }, + ], + }, + }, + ], + }, + }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request.ts b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request.ts new file mode 100644 index 0000000000..831a06761d --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/create-erc721-mint-request.ts @@ -0,0 +1,24 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function createMintRequestWithTokenId( + chainName: string, + contractAddress: string, + owner_address: string, + reference_id: string, + token_id: string +): Promise { + return await client.createMintRequest({ + chainName, + contractAddress, + createMintRequestRequest: { + assets: [ + { + owner_address, + reference_id, + token_id, + }, + ], + }, + }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/get-mint-request.ts b/examples/blockchain-data/minting-api-examples-with-node/get-mint-request.ts new file mode 100644 index 0000000000..4f72559d53 --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/get-mint-request.ts @@ -0,0 +1,10 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function getMintRequest( + chainName: string, + contractAddress: string, + referenceId: string +): Promise { + return await client.getMintRequest({ chainName, contractAddress, referenceId }); +} diff --git a/examples/blockchain-data/minting-api-examples-with-node/list-mint-requests.ts b/examples/blockchain-data/minting-api-examples-with-node/list-mint-requests.ts new file mode 100644 index 0000000000..41e9248237 --- /dev/null +++ b/examples/blockchain-data/minting-api-examples-with-node/list-mint-requests.ts @@ -0,0 +1,9 @@ +import { blockchainData } from "@imtbl/sdk"; +import { client } from "../lib"; + +export async function listMintRequests( + chainName: string, + contractAddress: string, +): Promise { + return await client.listMintRequests({ chainName, contractAddress }); +} diff --git a/examples/minting/README.md b/examples/minting/README.md deleted file mode 100644 index b5f8f3ea0b..0000000000 --- a/examples/minting/README.md +++ /dev/null @@ -1 +0,0 @@ -# Coming Soon™ \ No newline at end of file