Closed fakebl0ck closed 7 months ago
Can you check if you get the same error when using solders.transaction.Transaction?
Haven't tried with solders.transaction.Transaction but found the issue is gone when explicitly setting the fee payer during the construction of the Transaction object
transaction = Transaction(fee_payer=sender)
transaction.add(set_compute_unit_limit(1_000_000))
transaction.add(set_compute_unit_price(1_000))
transaction.add(transfer(TransferParams(
from_pubkey=sender.pubkey(),
to_pubkey=receiver.pubkey(),
lamports=int(0.001*LAMPORT_PER_SOL))
))
signature = client.send_transaction(transaction, sender)
It looks like when not explicitly setting the fee_payer, solana.transaction grabs the first account of the message to use as the fee payer, that's why it was working before adding the instructions ahead of the transfer.
FB
My point was I don't think this is a Solders issue, Solders is just where the error bubbles up
Also had this issue. Fixed it by @kevinheavey 's suggestion to use Solder's transaction class instead of solana's
If using solana.transaction,
from solana.transaction import Transaction
from solders.message import Message
from solders.transaction import Transaction as SoldersTransaction
blockhash = client.get_latest_blockhash().value.blockhash # a solana client
sender = Keypair.from_base58_string("") # some bs58 string
messages = Message([
set_compute_unit_price(1_000), # priority fee
transfer(TransferParams(
from_pubkey=sender.pubkey(),
to_pubkey=receiver,
lamports=int(txn.amount) # amt of lamports to transfer
))
], sender.pubkey())
solders_txn = SoldersTransaction([sender], messages, blockhash)
tx = Transaction().from_solders(solders_txn)
tx_resp = client.send_transaction(tx, sender)```
Also had this issue. Fixed it by @kevinheavey 's suggestion to use Solder's transaction class instead of solana's
If using solana.transaction,
from solana.transaction import Transaction from solders.message import Message from solders.transaction import Transaction as SoldersTransaction blockhash = client.get_latest_blockhash().value.blockhash # a solana client sender = Keypair.from_base58_string("") # some bs58 string messages = Message([ set_compute_unit_price(1_000), # priority fee transfer(TransferParams( from_pubkey=sender.pubkey(), to_pubkey=receiver, lamports=int(txn.amount) # amt of lamports to transfer )) ], sender.pubkey()) solders_txn = SoldersTransaction([sender], messages, blockhash) tx = Transaction().from_solders(solders_txn) tx_resp = client.send_transaction(tx, sender)```
AttributeError: 'Transaction' object has no attribute 'from_solders'
Getting this error when trying to set compute units:
solders.SignerError: not enough signers
Simple code example:
There is no error when removing the 2 instructions for setting compute units.