Solana发送含Memo的交易报错Node is unhealthy求助
解决Solana发送含Memo程序交易时的"Node is unhealthy"错误
问题概述
在Solana中发送包含Memo程序的交易时,CLI和web3.js环境均返回Node is unhealthy错误,已尝试删除重装node_modules,怀疑是RPC节点问题。
CLI命令及报错
- 执行的CLI命令:
solana transfer --from ./.cache/solana.json RECIVER_PUBLIC_KEY 0.00001 --allow-unfunded-recipient --url https://api.testnet.solana.com --fee-payer ./.cache/solana.json --with-memo hello
- 返回错误:
Error: RPC response error -32005: Node is unhealthy
TypeScript代码及报错
代码片段
async function sendRawTransaction(message:string):Promise<string>{ const connection = await new Connection(CONNECTION_STRING); let tx = new Transaction().add( SystemProgram.transfer({ fromPubkey: WALLET.publicKey, toPubkey: RECIVER_ADDRESS, lamports: 0, }), ); await tx.add( new TransactionInstruction({ keys: [{ pubkey: WALLET.publicKey, isSigner: true, isWritable: true }], data: Buffer.from(message, "utf-8"), programId: MEMO_PROGRAM, }) ); return new Promise((res, rej)=>{ sendAndConfirmTransaction(connection, tx, [WALLET]).then(s=>{ console.log(s) res(s) }).catch(e=>{ console.log(e) rej(e) }) }) }
报错信息
SendTransactionError: failed to send transaction: Node is unhealthy at Connection.sendEncodedTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:6812:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.sendRawTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:6769:20) at async Connection.sendTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:6759:12) at async sendAndConfirmTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:2219:21) { logs: undefined } node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise */); ^ SendTransactionError: failed to send transaction: Node is unhealthy at Connection.sendEncodedTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:6812:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.sendRawTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:6769:20) at async Connection.sendTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:6759:12) at async sendAndConfirmTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/@solana/web3.js/lib/index.cjs.js:2219:21) { logs: undefined } Node.js v18.4.0 [nodemon] app crashed - waiting for file changes before starting...
解决方法
- 更换RPC节点:官方公共测试网节点可能负载过高,替换CLI的
--url参数或代码中的CONNECTION_STRING为第三方测试网RPC地址。 - 检查节点状态:执行
solana cluster-info --url https://api.testnet.solana.com命令,确认官方节点是否处于健康状态。 - 调整交易参数:代码中
SystemProgram.transfer设置了lamports:0,部分节点可能限制0转账,尝试设置极小值(如1 lamport)后重试。 - 重试交易:临时节点波动可能导致报错,间隔一段时间后重新发送交易。
- 验证Memo程序ID:确保使用的
MEMO_PROGRAM为正确地址Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo,避免地址错误导致交易被拒绝。
内容的提问来源于stack exchange,提问作者Sbardi fx
相关产品推荐
相关产品推荐

