Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arfathyahiya opened this issue Jul 3, 2024 · 2 comments
Labels
question Further information is requested

Comments

@arfathyahiya
Copy link

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
Copy link
Contributor

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>

@buffalojoec buffalojoec added the question Further information is requested label Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

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.

@github-actions github-actions bot closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants