import * as dotenv from 'dotenv';
dotenv.config();
import { getKeypairFromEnvironment } from '@solana-developers/helpers';
const keypair = getKeypairFromEnvironment("SECRET_KEY");
console.log("Public Key:", keypair.publicKey.toString());
console.log("Private Key:", keypair.secretKey);
Output Generated is Public Key: HprpzYy7V6fJx2RCxsUUb9TtsFn8cY5mo2ZyoF2aowVi Private Key: Uint8Array(64) [ 79, 188, 209, 86, 157, 233, 52, 172, 3, 196, 91, 151, 109, 136, 74, 225, 198, 59, 224, 15, 173, 34, 85, 233, 75, 44, 212, 164, 111, 85, 175, 238, 249, 253, 161, 1, 119, 173, 57, 39, 187, 150, 243, 216, 59, 52, 191, 4, 68, 53, 177, 12, 253, 170, 172, 69, 68, 195, 85, 207, 241, 168, 202, 121 ]
But when i run another program that also needs keypair
import * as dotenv from 'dotenv';
dotenv.config();
import {
getExplorerLink, getKeypairFromEnvironment,
} from "@solana-developers/helpers";
import { mintTo } from "@solana/spl-token";
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"));
// Our token has two decimal places
const MINOR_UNITS_PER_MAJOR_UNITS = Math.pow(10, 2);
const user = await getKeypairFromEnvironment("SECRET_KEY");
// Subtitute in your token mint account from create-token-mint.ts
const tokenMintAccount = new PublicKey(
"YOUR_TOKEN_MINT_ACCOUNT"
);
// Substitute in your own, or a friend's token account address, based on the previous step.
const recipientAssociatedTokenAccount = new PublicKey(
"RECIPIENT_TOKEN_ACCOUNT"
);
const transactionSignature = await mintTo(
connection,
user,
tokenMintAccount,
recipientAssociatedTokenAccount,
user,
10 * MINOR_UNITS_PER_MAJOR_UNITS
);
const link = getExplorerLink("transaction", transactionSignature, "devnet");
console.log(`✅ Success! Mint Token Transaction: ${link}`);
I always get this error:
PS F:\solana\tokens-tokenprograms> npx esrun mint-tokens.ts node:internal/modules/run_main:129 triggerUncaughtException( ^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'F:\solana\tokens-tokenprograms\node_modules.bin\node_modules@solana-developers\helpers\dist\index.js' imported from F:\solana\tokens-tokenprograms\node_modules.bin\esrun-1716019772445.tmp.mjs Did you mean to import "../@solana-developers/helpers/dist/index.js"? at finalizeResolution (node:internal/modules/esm/resolve:265:11) at moduleResolve (node:internal/modules/esm/resolve:933:10) at defaultResolve (node:internal/modules/esm/resolve:1157:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38) at ModuleWrap. (node:internal/modules/esm/module_job:87:39) at link (node:internal/modules/esm/module_job:86:36) { code: 'ERR_MODULE_NOT_FOUND', url: 'file:///F:/solana/tokens-tokenprograms/node_modules/.bin/node_modules/@solana-developers/helpers/dist/index.js' }
Node.js v20.13.1