-
Notifications
You must be signed in to change notification settings - Fork 915
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
transfer spl token, block height exceeded error #2361
Comments
Hello, I'm a bit skeptical that this is a bug with Web3.js, since you mention the code has been working for some time. Have you recently upgraded your version of It's more likely this is an issue with network congestion and lack of priority fees, which solutions are in development for. Could you share which network you're attempting to send this transaction to? The fact that the transaction is submitting successfully, but is not getting confirmed within the blockhash time limit leads me to believe the problem is not within Web3.js. |
this is probably 100% caused by not using priority fees. lately when you submit a transaction if you are not including a priority fee in your transaction the validators will not pick up your transaction in time before the block expires which results in this error. |
Hi @shahram0102, 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 the Solana JavaScript SDK itself. Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with the Solana JavaScript SDK 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. |
Yes, that was the problem and I fixed it. Before, there was no need to set priority fees. Even now, if priority fees are not registered, sometimes the transaction is approved. |
Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up. |
Overview
transfer spl token in node js
Steps to reproduce
import * as splToken from "@solana/spl-token";
import {
Keypair,
PublicKey,
sendAndConfirmTransaction,
Transaction,
} from "@solana/web3.js";
import bs58 from "bs58";
import createHttpError from "http-errors";
import tokens, { TokenName } from "
/constants/token.constant";/env";import { env } from "
import solanaConnection from "~/utils/solanaConnection.util";
const publicKey = new PublicKey(env.OWNER_SOLANA_WALLET_ADDRESS);
const privateKeyBytes = bs58.decode(env.OWNER_SOLANA_WALLET_PRIVATE_KEY);
const keypair = Keypair.fromSecretKey(privateKeyBytes);
const secretKey = keypair.secretKey;
const payer = { publicKey, secretKey };
const { mintId, decimals, programId } = tokens.evol;
const mintPublicKey = new PublicKey(mintId);
export default async function transferSolanaToken(to: string, amount: number) {
try {
const fromTokenAccount = await splToken.getOrCreateAssociatedTokenAccount(
solanaConnection,
payer,
mintPublicKey,
publicKey,
undefined,
undefined,
undefined,
new PublicKey(programId),
);
} catch (error) {
console.log("🚀 ~ transferSolanaToken ~ error:", error);
}
}
Description of bug
🚀 ~ transferSolanaToken ~ error: TransactionExpiredBlockheightExceededError: Signature 2aCzLc1BfKQc99tDGZj5muDhu7eSimu7k2YTPh5nBrGVnNeta51qYkTQWSTUsSFPSfnEPgmLg87oNvrW4H62W6Q has expired: block height exceeded.
at Connection.confirmTransactionUsingBlockHeightExceedanceStrategy (webpack-internal:///(rsc)/./node_modules/.pnpm/@Solana+web3.js@1.91.1/node_modules/@solana/web3.js/lib/index.esm.js:5855:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Connection.confirmTransaction (webpack-internal:///(rsc)/./node_modules/.pnpm/@Solana+web3.js@1.91.1/node_modules/@solana/web3.js/lib/index.esm.js:5695:20)
at async sendAndConfirmTransaction (webpack-internal:///(rsc)/./node_modules/.pnpm/@Solana+web3.js@1.91.1/node_modules/@solana/web3.js/lib/index.esm.js:2091:19)
at async transferSolanaToken (webpack-internal:///(rsc)/./src/utils/transfer/transferSolanaToken.util.ts:47:38)
at async withdraw (webpack-internal:///(rsc)/./src/server/services/withdraw.services.ts:77:36)
at async POST (webpack-internal:///(rsc)/./src/app/api/withdraw/route.ts:9:12)
at async D:\projects\coin-flip\node_modules.pnpm\next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:62609 {
signature: '2aCzLc1BfKQc99tDGZj5muDhu7eSimu7k2YTPh5nBrGVnNeta51qYkTQWSTUsSFPSfnEPgmLg87oNvrW4H62W6Q'
}
----------
I used to use this code without any problem, but this problem has appeared recently. It has been almost a month since it had a problem, otherwise it was working without problems
The text was updated successfully, but these errors were encountered: