Quantcast
Channel: Trying to send specific SPL Token but creates new token instead - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 2

Trying to send specific SPL Token but creates new token instead

$
0
0

I'm trying to send a SPL Token but when I execute the code below it creates an unknown token and sends it, It does not recognize the token address / programID. Where should I pass the token address?

    const mint = await createMint(      connection,      fromAddress.addressKeypair,      fromAddress.addressKeypair.publicKey,      null,      9,      undefined,      {},"7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx".TOKEN_PROGRAM_ID    );    console.log(mint);    // Get the token account of the fromWallet address, and if it does not exist, create it    const fromTokenAccount = await getOrCreateAssociatedTokenAccount(      connection,      fromAddress.addressKeypair,      mint,      fromAddress.addressKeypair.publicKey,"7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx".TOKEN_PROGRAM_ID    );    // Get the token account of the toWallet address, and if it does not exist, create it    const toTokenAccount = await getOrCreateAssociatedTokenAccount(      connection,      fromAddress.addressKeypair,      mint,      toaddress,"7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx".TOKEN_PROGRAM_ID    );    // Mint 1 new token to the "fromTokenAccount" account we just created    let signature = await mintTo(      connection,      fromAddress.addressKeypair,      mint,      fromTokenAccount.address,      fromAddress.addressKeypair.publicKey,      1000000000,      undefined,      {},"7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx".TOKEN_PROGRAM_ID    );    console.log("mint tx:", signature);    // Transfer the new token to the "toTokenAccount" we just created    signature = await transfer(      connection,      fromAddress.addressKeypair,      fromTokenAccount.address,      toTokenAccount.address,      fromAddress.addressKeypair.publicKey,      amount,      undefined,      {},"7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx".TOKEN_PROGRAM_ID    );     console.log("sig: ", signature);    response["result"] = 1;    response["data"] = { txid: signature };    response["error"] = null;    return console.log(response);  } catch (error) {    response["result"] = 0;    response["data"] = { txid: null };    response["error"] = error;    return console.log(response);  }

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images