Here's my code i'm trying to mint spl token using spl js library:
(async () => {
const connection = new web3.Connection(web3.clusterApiUrl("devnet"));
let secretKey = Uint8Array.from([
186, 104, 237, 47, 123, 227, 2, 226, 150, 7, 169, 40, 252, 67, 161, 86, 198,....
183, 130, 31, 174, 135, 153, 46, 227, 154, 125, 20, 79, 209,
]);
const myKeypair = web3.Keypair.fromSecretKey(secretKey);
console.log(myKeypair.publicKey);
mint = await splToken.createMint(
connection,
myKeypair,
myKeypair.publicKey,
null,
9,
splToken.TOKEN_PROGRAM_ID
);
console.log("mint:"+mint);
})();
This is the error im getting:
solana/node_modules/@solana/web3.js/lib/index.cjs.js:1791 const key = signer.publicKey.toString(); ^
TypeError: Cannot read properties of undefined (reading 'toString') at Transaction.sign solana/node_modules/@solana/web3.js/lib/index.cjs.js:1791:36) at Connection.sendTransaction solana/node_modules/@solana/web3.js/lib/index.cjs.js:9676:21)
those are the parameters for
createMint()
Last one type is
Keypair
. but you are passingsplToken.TOKEN_PROGRAM_ID
which isPublicKey
. you need to create another keypair for the last arg