solana-labs / solana-program-library

A collection of Solana programs maintained by Solana Labs
https://solanalabs.com
Apache License 2.0
3.48k stars 2.05k forks source link

createMint Throwing TypeError: Cannot read properties of null (reading 'toBuffer') #6977

Closed arfathyahiya closed 3 months ago

arfathyahiya commented 3 months ago

Some of the solana packages I've along with their versions @solana/web3.js: 1.94.0 @solana/wallet-adapter-base: 0.9.23 @solana/spl-token: 0.4.6 @solana/spl-token-group: 0.0.3

When trying to use createMint It's throwing me this error

D:\test\node_modules\@solana\buffer-layout-utils\src\web3.ts:17
        const src = publicKey.toBuffer();
                              ^
TypeError: Cannot read properties of null (reading 'toBuffer')
    at Blob.publicKeyLayout.encode (D:\test\@solana\buffer-layout-utils\src\web3.ts:17:31)
    at Structure.encode (D:\test\node_modules\@solana\buffer-layout\src\Layout.ts:1205:26)
    at createInitializeMint2Instruction (D:\test\node_modules\@solana\spl-token\src\instructions\initializeMint2.ts:52:36)
    at D:\test\node_modules\@solana\spl-token\src\actions\createMint.ts:41:41
    at Generator.next (<anonymous>)
    at fulfilled (D:\test\node_modules\@solana\spl-token\lib\cjs\actions\createMint.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Code:

import { createMint } from "@solana/spl-token";
const mint = await createMint(
    connection, 
    Keypair.fromSecretKey(base58.decode(secretKey)),
    null,
    null,
    9,
    Keypair.generate(),
    {skipPreflight: true, maxRetries: 2}
);
buffalojoec commented 3 months ago

You're passing null instead of a PublicKey for the third argument.

export async function createMint(
    connection: Connection,
    payer: Signer,
    mintAuthority: PublicKey, // <-- Right here.
    /* ... */
): Promise<PublicKey>
github-actions[bot] commented 3 months ago

Hi @arfathyahiya,

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of Solana itself.

Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with Solana itself, please post your question to the Solana Stack Exchange using this link: https://solana.stackexchange.com/questions/ask


This automated message is a result of having added the ‘question’ tag.