Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

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

Closed
@arfathyahiya

Description

@arfathyahiya

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}
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions