Skip to content

Commit

Permalink
GMS-2160 Add minting API code examples (#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiep-immutable authored Sep 19, 2024
1 parent 77a9ec7 commit 9ac8932
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<blockchainData.Types.CreateMintRequestResult> {
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",
},
],
},
},
],
},
});
}
Original file line number Diff line number Diff line change
@@ -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<blockchainData.Types.CreateMintRequestResult> {
return await client.createMintRequest({
chainName,
contractAddress,
createMintRequestRequest: {
assets: [
{
owner_address,
reference_id,
token_id,
amount,
},
],
},
});
}
Original file line number Diff line number Diff line change
@@ -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<blockchainData.Types.CreateMintRequestResult> {
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",
},
],
},
},
],
},
});
}
Original file line number Diff line number Diff line change
@@ -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<blockchainData.Types.CreateMintRequestResult> {
return await client.createMintRequest({
chainName,
contractAddress,
createMintRequestRequest: {
assets: [
{
owner_address,
reference_id,
},
],
},
});
}
Original file line number Diff line number Diff line change
@@ -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<blockchainData.Types.CreateMintRequestResult> {
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",
},
],
},
},
],
},
});
}
Original file line number Diff line number Diff line change
@@ -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<blockchainData.Types.CreateMintRequestResult> {
return await client.createMintRequest({
chainName,
contractAddress,
createMintRequestRequest: {
assets: [
{
owner_address,
reference_id,
token_id,
},
],
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { blockchainData } from "@imtbl/sdk";
import { client } from "../lib";

export async function getMintRequest(
chainName: string,
contractAddress: string,
referenceId: string
): Promise<blockchainData.Types.ListMintRequestsResult> {
return await client.getMintRequest({ chainName, contractAddress, referenceId });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { blockchainData } from "@imtbl/sdk";
import { client } from "../lib";

export async function listMintRequests(
chainName: string,
contractAddress: string,
): Promise<blockchainData.Types.ListMintRequestsResult> {
return await client.listMintRequests({ chainName, contractAddress });
}
1 change: 0 additions & 1 deletion examples/minting/README.md

This file was deleted.

0 comments on commit 9ac8932

Please sign in to comment.