Open chiwalfrm opened 8 months ago
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 send_transaction
?
I failed 100% in the last two days... Transactions don't get in blockchain even if specifying setComputeUnitPrice/setComputeUnitLimit instructions
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?
I failed 100% in the last two days... Transactions don't get in blockchain even if specifying setComputeUnitPrice/setComputeUnitLimit instructions
The problem turned out to be in the RPC nodes (specifically Alchemy and GetBlock). After switching to the Quicknode, the problem mostly vanished.
can show us the code?
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 failed 100% in the last two days... Transactions don't get in blockchain even if specifying setComputeUnitPrice/setComputeUnitLimit instructions
The problem turned out to be in the RPC nodes (specifically Alchemy and GetBlock). After switching to the Quicknode, the problem mostly vanished.
can show us the code?
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: opts = TxOpts(skip_confirmation=False, preflight_commitment="confirmed")
and add retry logic
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: