Reputation: 5
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)
Upvotes: 0
Views: 325
Reputation: 49571
those are the parameters for createMint()
@param connection — Connection to use
@param payer — Payer of the transaction and initialization fees
@param mintAuthority — Account or multisig that will control minting
@param freezeAuthority — Optional account or multisig that can freeze token accounts
@param decimals — Location of the decimal place
@param keypair — Optional keypair, defaulting to a new random one
Last one type is Keypair
. but you are passing splToken.TOKEN_PROGRAM_ID
which is PublicKey
. you need to create another keypair for the last arg
Upvotes: 0