Skip to main content

FA2 Transfer

The FA2 Transfer feature in the Beacon SDK is designed for handling token transfers using the FA2 standard on the Tezos blockchain. FA2 is a multi-asset interface, enabling a wide range of token types and configurations, including fungible, non-fungible, and multi-asset tokens.

Live Editor
import { TezosToolkit } from "@taquito/taquito";
import { BeaconWallet } from "@taquito/beacon-wallet";

const Tezos = new TezosToolkit("https://mainnet.api.tez.ie");
const wallet = new BeaconWallet({ name: "Beacon Docs" });

Tezos.setWalletProvider(wallet);

const address = await wallet.getPKH();
if (!address) {
  await wallet.requestPermissions();
}

// Connect to a specific contract on the tezos blockchain.
// Make sure the contract is deployed on the network you requested permissions for.
const contract = await Tezos.wallet.at(
  "KT1CpeSQKdkhWi4pinYcseCFKmDhs5M74BkU", // For this example, we use the tzcolors contract on mainnet.
);

const TOKEN_ID = 0; // FA2 token id
const recipient = address; // Send to ourself

// Call a method on the contract. In this case, we use the transfer entrypoint.
// Taquito will automatically check if the entrypoint exists and if we call it with the right parameters.
// In this case the parameters are [from, to, amount].
// This will prepare the contract call and send the request to the connected wallet.
const result = await contract.methods
  .transfer([
    {
      from_: address,
      txs: [
        {
          to_: recipient,
          token_id: TOKEN_ID,
          amount: 1,
        },
      ],
    },
  ])
  .send();

// As soon as the operation is broadcasted, you will receive the operation hash
return result.opHash;
Loading...