-
Notifications
You must be signed in to change notification settings - Fork 240
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
Any way to use send_transaction() reliably? #399
Comments
It is so unreliable I don't know what I am doing wrong. >50% failure rate. When it works, the function comes back in 5 seconds, and when it fails, it takes 90 seconds and then comes back with "Error: Unable to confirm transaction " |
same problem here. what is the best practices for |
I failed 100% in the last two days... Transactions don't get in blockchain even if specifying setComputeUnitPrice/setComputeUnitLimit instructions |
can show us the code? |
The problem turned out to be in the RPC nodes (specifically Alchemy and GetBlock). After switching to the Quicknode, the problem mostly vanished.
I can't show the exact code because it contains some business logic, but it is very similar to this one: from decimal import Decimal
from solana.rpc.api import Client
from solana.transaction import Transaction
from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price
from solders.keypair import Keypair
from solders.pubkey import Pubkey
from solders.system_program import TransferParams, transfer
src: Keypair = ...
dst: Pubkey = ...
sol_amount = Decimal("0.5")
sol_lamports = Decimal("1e+9")
tx = Transaction(fee_payer=src.pubkey())
# SOL transfer
tx.add(
transfer(
TransferParams(
from_pubkey=src.pubkey(),
to_pubkey=dst,
lamports=int(sol_amount * sol_lamports),
)
)
)
# Extra fee
tx.add(set_compute_unit_limit(300_000))
tx.add(set_compute_unit_price(1000))
client = Client()
tx_sig = client.send_transaction(tx, src).value
client.confirm_transaction(tx_sig) |
I think you can adjust the TxOpts like: |
I have a lot of problems with send_transaction(), in that I get a lot of timeouts. The errors look like this.
Since I want to use this to send to many addresses and reliability is needed, what can I do to prevent these 'Unable to confirm transaction' errors?
This is the line that I use to send the transaction:
The text was updated successfully, but these errors were encountered: