I am trying to buy a token through solana.ру, but in the process of writing the code, I get an error

from solana.rpc.api import Client, Keypair, Pubkey
from spl.token.constants import TOKEN_PROGRAM_ID
from spl.token.client import Token

wallet_secret_key = Keypair.from_bytes([227,...,52]) 
wallet_public_key = Pubkey.from_string("6vp...Kyu") 
target_spl_mint = Pubkey.from_string('3Pd...br9')
amount_to_buy = 1000 
program_id = TOKEN_PROGRAM_ID

client = Client('https://api.mainnet-beta.solana.com')

token = Token(conn=client, pubkey=target_spl_mint,program_id=program_id,payer=wallet_secret_key)
blockhash = client.get_latest_blockhash().value.blockhash
#The error is here 
transaction = token.mint_to(recent_blockhash=blockhash,dest=wallet_public_key,mint_authority=target_spl_mint,amount=amount_to_buy)
tx_id = client.send_transaction(transaction, wallet_secret_key)
print(f"Транзакция отправлена. ID: {tx_id}")


    self._solders.sign(signers, self._solders.message.recent_blockhash)
solders.SignerError: not enough signers

I'm just at the beginning of learning solana and spl.token. If I have chosen the wrong method to purchase tokens for sol, please let me know.

Thank You

1 Answer 1


Since you're using the mint_to command on the client, you're not buying tokens, you're trying to create new tokens. Only the mint authority has the ability to create new tokens on a mint.

If you want to trade SOL for other tokens, you need to use some on-chain trading protocol, like an automated market-maker (AMM) or a central limit order book (CLOB). I won't recommend particular products here, but you can do some research on AMMs and CLOBs on Solana. Once you learn about them, you can look into any dev libraries that they may have in order to trade the tokens that interest you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.