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

Issues with @solana/spl-tokens pnpm is not saving this package to where I can't connect to the blockchain with the .js file I created like: #5902

Closed
bps1980 opened this issue Nov 27, 2023 · 2 comments
Labels
question Further information is requested

Comments

@bps1980
Copy link

bps1980 commented Nov 27, 2023

const { Token, TOKEN_PROGRAM_ID } = require("@solana/spl-token");
const { Connection, PublicKey, Keypair } = require("@solana/web3.js");

async function main() {
// Your existing mint, payer, and recipient details
const mintPublicKey = new PublicKey("");
const recipientTokenAccount = new PublicKey("");
const payerKeypair = Keypair.generate(); // Your account that will pay for the transaction

// Establish a connection to the cluster
const connection = new Connection([link](https://rpc.ankr.com/solana_devnet/a62e9ca39b1ccedf47c1bd02af472a2438212b774438f46c4b8b10b3cb681d36), "confirmed");

// Create a new token instance
const token = new Token(
    connection,
    mintPublicKey,
    TOKEN_PROGRAM_ID,
    payerKeypair // Use the payer's keypair for signing transactions
);

// Amount to mint (consider decimals)
const amountToMint = 150000000; // Adjust based on your token's decimals

// Minting new tokens to the recipient's token account
await token.mintTo(
    recipientTokenAccount, // Token account of the recipient
    payerKeypair.publicKey, // Payer of the transaction
    [], // Multisig owners (if applicable)
    amountToMint // Amount to mint
);

console.log(`Minted ${amountToMint} tokens to ${recipientTokenAccount.toString()}`);

}

main().catch(err => {
console.error("Error executing the script:", err);
});

After running pnpm install @solana/spl-tokens, I get still:

node:internal/modules/cjs/loader:1147
throw err;
^

Error: Cannot find module '@solana/spl-token'
Require stack:

  • /mnt/c/Users/segura23/SeguraSafeSwap_Token/SeguraSafeSwap_Solana3/solana-program-library/services/js/blockchainConnection.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object. (/mnt/c/Users/segura23/SeguraSafeSwap_Token/SeguraSafeSwap_Solana3/solana-program-library/services/js/blockchainConnection.js:1:37)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/mnt/c/Users/segura23/SeguraSafeSwap_Token/SeguraSafeSwap_Solana3/solana-program-library/services/js/blockchainConnection.js'
    ]
    }

Node.js v21.2.0

@bps1980
Copy link
Author

bps1980 commented Nov 27, 2023

sorry @solana/spl-token

@joncinque joncinque added the question Further information is requested label Nov 27, 2023
Copy link
Contributor

Hi @bps1980,

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.

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