I minted an NFT from a Candy Machine, and I want to transfer it to another wallet, but I'm not sure how to generate the Token object in order to do a transfer.
import { Keypair, Connection, clusterApiUrl, PublicKey } from '@solana/web3.js';
import splToken from "@solana/spl-token";
const connection = new Connection(clusterApiUrl('devnet'));
const secretKey = new Uint8Array([...])
const fromWallet = Keypair.fromSecretKey(secretKey);
var myToken = new splToken.Token(
connection,
publicKey, // What address do I use here?
TOKEN_METADATA_PROGRAM_ID,
fromWallet
);
I keep getting this error, and I'm not sure what public key I'm supposed to use. I assumed it's the address of the token, but nothing I try works.
TypeError: Cannot read properties of undefined (reading 'Token')