when I transfer nft to my another account. It makes error.
export const createWalletKey = async () => {
const bs58 = require("bs58");
const bs = bs58.decode(secretKey);
const wallet = Keypair.fromSecretKey(bs); // get wallet keypair
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
connectWithMetaplex(wallet);
};
export const connectWithMetaplex = async wallet => {
const bs58 = require("bs58");
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const bs = bs58.decode(anotherSecretKey);
const toWallet = Keypair.fromSecretKey(bs); // get wallet keypair
const metaplex = Metaplex.make(connection).use(keypairIdentity(wallet));
const { nft } = await metaplex
.nfts()
.create({
uri: "",
name: "JERRY NFT",
sellerFeeBasisPoints: 100,
})
.run();
const fromTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
wallet,
nft.mintAddress,
wallet.publicKey,
);
console.log("fromTokenAccount", fromTokenAccount.address.toString());
const toTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
wallet,
nft.mintAddress,
toWallet.publicKey,
);
console.log(LAMPORTS_PER_SOL);
const transaction = new Transaction().add(
createTransferInstruction(
fromTokenAccount.address,
toTokenAccount.address,
wallet.publicKey,
LAMPORTS_PER_SOL * 10,
[],
TOKEN_PROGRAM_ID,
),
);
const blockHash = await connection.getLatestBlockhash();
transaction.feePayer = await wallet.publicKey;
transaction.recentBlockhash = await blockHash.blockhash;
console.log(transaction);
};
I have 10 SOL in devnet :(