Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7969

Trouble sending faucet SOL on devnet from one wallet to another

$
0
0

I've attempted to send funds from one wallet to another. The wallet I intend to send from is credited with 5 SOL and the recipient wallet has 1 SOL. I run either npx esrun transfer.ts 4UVALcW69V3XMeEVqnDqciv1y17kPEdsSmKodHiqf9nN or ts-node transfer.ts 4UVALcW69V3XMeEVqnDqciv1y17kPEdsSmKodHiqf9nN yet I get these errors respectively,

PS C:\Users\Student\Documents\Solana_Web3\generate-keypair> npx esrun .\transfer.ts 4UVALcW69V3XMeEVqnDqciv1y17kPEdsSmKodHiqf9nNnode:internal/process/esm_loader:108    internalBinding('errors').triggerUncaughtException(                              ^Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\Student\Documents\Solana_Web3\generate-keypair\node_modules\.bin\node_modules\@solana\web3.js\lib\index.cjs.js' imported from C:\Users\Student\Documents\Solana_Web3\generate-keypair\node_modules\.bin\esrun-1704630798378.tmp.mjsDid you mean to import ../../@solana/web3.js/lib/index.cjs.js?    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)    at new NodeError (node:internal/errors:405:5)    at finalizeResolution (node:internal/modules/esm/resolve:327:11)    at moduleResolve (node:internal/modules/esm/resolve:946:10)    at defaultResolve (node:internal/modules/esm/resolve:1132:11)    at nextResolve (node:internal/modules/esm/loader:163:28)    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)    at link (node:internal/modules/esm/module_job:76:36) {  code: 'ERR_MODULE_NOT_FOUND'}Node.js v18.18.0

or

PS C:\Users\Student\Documents\Solana_Web3\generate-keypair> ts-node .\transfer.ts 4UVALcW69V3XMeEVqnDqciv1y17kPEdsSmKodHiqf9nN  bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)suppliedToPubkey: 4UVALcW69V3XMeEVqnDqciv1y17kPEdsSmKodHiqf9nN✅ Loaded our own keypair, the destination public key, and connected to SolanaError sending SOL: SendTransactionError: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.    at Connection.sendEncodedTransaction (C:\Users\Student\Documents\Solana_Web3\generate-keypair\node_modules\@solana\web3.js\src\connection.ts:5922:13)    at processTicksAndRejections (node:internal/process/task_queues:95:5)    at async Connection.sendRawTransaction (C:\Users\Student\Documents\Solana_Web3\generate-keypair\node_modules\@solana\web3.js\src\connection.ts:5881:20)    at async Connection.sendTransaction (C:\Users\Student\Documents\Solana_Web3\generate-keypair\node_modules\@solana\web3.js\src\connection.ts:5869:12)    at async sendAndConfirmTransaction (C:\Users\Student\Documents\Solana_Web3\generate-keypair\node_modules\@solana\web3.js\src\utils\send-and-confirm-transaction.ts:35:21)    at async sendSol (C:\Users\Student\Documents\Solana_Web3\generate-keypair\transfer.ts:46:27) {  logs: []}

This is my package.json file,

{"name": "generate-keypair","version": "1.0.0","description": "","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1","rebuild": "npm rebuild","start": "npm start transfer.ts"  },"keywords": [],"author": "","license": "ISC","dependencies": {"@solana-developers/node-helpers": "^1.2.1","@solana/web3.js": "^1.87.6","bs58": "^5.0.0","dotenv": "^16.3.1","esrun": "^3.2.26","typescript": "^5.3.3"  }}

This is my transfer.ts file,

    Connection,    Transaction,    SystemProgram,    sendAndConfirmTransaction,    PublicKey,} from "@solana/web3.js";import "dotenv/config"import { getKeypairFromEnvironment } from "@solana-developers/node-helpers";async function sendSol() {    try {        const suppliedToPubkey = process.argv[2] || null;        if (!suppliedToPubkey) {            console.log(`Please provide a public key to send to`);            process.exit(1);        }        const senderKeypair = getKeypairFromEnvironment("SECRET_KEY");        console.log(`suppliedToPubkey: ${suppliedToPubkey}`);        const toPubkey = new PublicKey(suppliedToPubkey);        const connection = new Connection("https://api.devnet.solana.com", "confirmed");        console.log(            `✅ Loaded our own keypair, the destination public key, and connected to Solana`        );        const transaction = new Transaction();        const LAMPORTS_TO_SEND = 5000;        const sendSolInstruction = SystemProgram.transfer({            fromPubkey: senderKeypair.publicKey,            toPubkey,            lamports: LAMPORTS_TO_SEND,        });        transaction.add(sendSolInstruction);        const signature = await sendAndConfirmTransaction(connection, transaction, [            senderKeypair,        ]);        console.log(            `💸 Finished! Sent ${LAMPORTS_TO_SEND} to the address ${toPubkey}. `        );        console.log(`Transaction signature is ${signature}!`);    } catch (error) {        console.error("Error sending SOL:", error);    }}sendSol();

May I get some help on where I've gone wrong please?


Viewing all articles
Browse latest Browse all 7969

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>