Skip to main content

useTransferNFT

Description

Hook for transferring an existing wallet.

Parameters

NameTypeDescription
fromstringThe address of the current token owner.
tostringThe address of the new token owner.
tokenIdnumberThe ID of the token to transfer.
[overrides]OverridesOptional overrides for the contract call.

Example

import { useContract, useTransferNFT } from "@openformat/react";

// address of a created NFT (ERC721) contract. You can get this from the subgraph.
const address = "0x123...";
const tokenId = 1;

// returns an instance of the NFT.
const { data: nft } = useContract(address);

const { data, transfer } = useTransferNFT(nft);

async function handleTransfer() {
await transfer({ from: "0x123...", to: "0x123...", tokenId: tokenId });
}