and apologies if there's a obvious better place to ask this.
I'm writing experimental Python 3.12 code to move SOL from/to an address I create "by hand" and a centralized exchange (Kraken), like this:
from solders.keypair import Keypair
import base58
# Create keys and a Solana address
by_hand_keypair = Keypair()
by_hand_sol_address = base58.b58encode(bytes(by_hand_keypair.pubkey())).decode("utf-8")
Now I then transferred 0.03 SOL to my new address via Kraken Pro and wait a bit...
# ... and check if it's there:
from solana.rpc.api import Client
client = Client("https://api.mainnet-beta.solana.com/")
print(f"New Solana address balance: {client.get_balance(by_hand_keypair.pubkey()).value}")
It is, showing the right balance (30000000)
Now I try to transfer some back
from solders.pubkey import Pubkey
from solana.transaction import Transaction
from solders.system_program import transfer
from solders.system_program import TransferParams
kraken_sol_address = "C2od3xYdTh4nbt9WP3mSN67rFhDZ3MGKood8LtyJGaui"
kraken_pub_key = Pubkey(base58.b58decode(kraken_sol_address))
blockhash = client.get_latest_blockhash().value.blockhash
transaction = Transaction(fee_payer=by_hand_keypair.pubkey(), recent_blockhash=blockhash)
transaction.add(
transfer(
TransferParams(
from_pubkey=by_hand_keypair.pubkey(),
to_pubkey=kraken_pub_key,
lamports=10000000
)
)
)
transaction.sign(by_hand_keypair)
response = client.send_transaction(transaction)
It's here I get the SignerError: not enough signers
What have I misunderstood?