Socket
Book a DemoInstallSign in
Socket

@futureverse/mint-sdk-react

Package Overview
Dependencies
Maintainers
18
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@futureverse/mint-sdk-react

## Installation

latest
npmnpm
Version
2.0.0
Version published
Weekly downloads
8
33.33%
Maintainers
18
Weekly downloads
 
Created
Source

Futureverse Mint SDK React

Installation

NPM:

    npm install @futureverse/mint-sdk-react --save

Yarn:

    yarn add @futureverse/mint-sdk-react

Usage

import {
  TrnApiProvider,
  useCreateAndSendExtrinsic,
  useTrnApi,
} from '@futureverse/mint-sdk-react';
import { useCallback } from 'react';
import { useSigner } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

function useCreateMintExtrinsic(
  collectionId: string,
  numberOfTokens: number,
  owner: string
) {
  const { trnApi } = useTrnApi();
  return trnApi.tx.nft.mint(collectionId, numberOfTokens, owner);
}

function ExtrinsicDemo() {
  const { trnApi } = useTrnApi();
  const { data: signer } = useSigner();

  const collectionId = '<your collection id>';
  const numberOfTokens = 1; // How many tokens to mint
  const address = 'FuturePass or address to mint to';
  const extrinsic = useCreateMintExtrinsic(
    collectionId,
    numberOfTokens,
    address
  );

  const { mutateAsync } = useCreateAndSendExtrinsic(trnApi);

  const submitTransaction = useCallback(async () => {
    if (!signer) return;
    const { result } = await mutateAsync({
      account: address,
      extrinsic,
      signer,
    });

    return result;
  }, [extrinsic, mutateAsync, signer]);

  // Your UI code to call submitTransaction
  return <></>;
}

const queryClient = new QueryClient();

function DemoApp() {
  return (
    // Provide a TRN API provider to your application
    // If using @futureverse/react you can exclude this provider
    // import { useTrnApi } from '@futureverse/react';
    <QueryClientProvider client={queryClient}>
      <TrnApiProvider network="porcini">
        <ExtrinsicDemo />
      </TrnApiProvider>
    </QueryClientProvider>
  );
}

FAQs

Package last updated on 07 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts