hello guys pls i get the error ( ERROR - Error sending transaction: 'result') in my below code, i'm making use of sol version 0.24.0 & python
def transfer_to_central_wallet(private_key: str, amount: float) -> bool: try: from_keypair = Keypair.from_secret_key(b58decode(private_key)) to_pubkey = PublicKey(CENTRAL_WALLET_ADDRESS)
# Get recent blockhash
recent_blockhash_resp = client.get_recent_blockhash()
recent_blockhash = recent_blockhash_resp['result']['value']['blockhash']
# Create transaction
lamports = int(amount * 1_000_000_000) # Convert SOL to lamports
tx = Transaction(recent_blockhash=recent_blockhash)
tx.add(
transfer(
TransferParams(
from_pubkey=from_keypair.public_key,
to_pubkey=to_pubkey,
lamports=lamports
)
)
)
# Sign transaction
tx.sign(from_keypair)
# Send transaction with TxOpts
opts = TxOpts(skip_preflight=False, preflight_commitment='confirmed')
response = client.send_raw_transaction(tx.serialize(), opts=opts)
logger.info(f"Transaction sent with signature: {response['result']}")
return True
except Exception as e:
logger.error(f"Error sending transaction: {str(e)}")
return False