🖼

Transfer NFTs

Transfer NFTs on any blockchain - ETH (Ethereum), BNB (Binance Smart Chain), MATIC (Polygon)

Transfer ERC721 Tokens (Non-Fungible)

To transfer ERC721 tokens, follow the steps:
  1. 1.
    Construct anoptionsobject and set
    1. 1.
      type:"erc721"
    2. 2.
      receiver: "0x000..." //wallet address
    3. 3.
      contractAddress: "0x..." //contract of the ERC721 token
    4. 4.
      tokenId: 1
  2. 2.
    Call the Moralis transfer function as shown below
As it's only possible to transfer one ERC721 at a time, no amountisneeded.
JS
React
// sending a token with token id = 1
const options = {
type: "erc721",
receiver: "0x..",
contractAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
tokenId: 1,
};
let transaction = await Moralis.transfer(options);
import React from "react";
import { useWeb3Transfer } from "react-moralis";
​
const TransferNFT = () => {
const { fetch, error, isFetching } = useWeb3Transfer({
type: "erc721",
receiver: "0x..",
contractAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
tokenId: 1,
});
​
return (
// Use your custom error component to show errors
<div>
{error && <ErrorMessage error={error} />}
<button onClick={() => fetch()} disabled={isFetching}>
Transfer
</button>
</div>
);
};

Transferring ERC1155 Tokens (Semi-Fungible)

To transfer ERC1155 tokens, follow the steps:
  1. 1.
    Construct anoptionsobject and set
    1. 1.
      type:"erc721"
    2. 2.
      receiver: "0x000..." //wallet address
    3. 3.
      contractAddress: "0x..." //contract of the ERC721 token
    4. 4.
      tokenId: 1
    5. 5.
      amount: 15 //number of tokens to transfer
  2. 2.
    Call the Moralis transfer function as shown below
JS
React
// sending 15 tokens with token id = 1
const options = {
type: "erc1155",
receiver: "0x..",
contractAddress: "0x..",
tokenId: 1,
amount: 15,
};
let transaction = await Moralis.transfer(options);
import React from "react";
import { useWeb3Transfer } from "react-moralis";
​
const TransferNFT = () => {
const { fetch, error, isFetching } = useWeb3Transfer({
type: "erc1155",
receiver: "0x..",
contractAddress: "0x..",
tokenId: 1,
amount: 15,
});
​
return (
// Use your custom error component to show errors
<div>
{error && <ErrorMessage error={error} />}
<button onClick={() => fetch()} disabled={isFetching}>
Transfer
</button>
</div>
);
};

Resolving the results

Moralis.transfer() returns a transaction response after it is executed. The below page shows how to consume the data returned.