Open SeveighTech-Management opened 1 year ago
I know having this would definitely have saved me two days' worth of work.
Thanks @seveightech was looking for something like this
If you don't mind helping I'm stuck here with SignerError: keypair-pubkey mismatch and tried and checked almost everything IDK am I doing something wrong or why this issue persist
from solders.account import Account from solana.rpc.api import Client from solana.transaction import Transaction from spl.token.constants import TOKEN_PROGRAM_ID from spl.token.instructions import initialize_account, InitializeAccountParams from solders.pubkey import Pubkey from solana.blockhash import Hash kp = Keypair()
from solana.rpc.api import Client from solana.blockhash import Hash from solders.null_signer import NullSigner
recent_blockhash = client.get_latest_blockhash().value.blockhash
print(f"Most recent blockhash: {recent_blockhash}")
user2_public_key = kp.pubkey() spl_token_mint_address = Pubkey.from_string(Mint_Address["usdt"])
new_account = Account(lamports=100000, data=b"sys_user2", owner=kp.pubkey())
initialize_instruction = initialize_account(InitializeAccountParams( TOKEN_PROGRAM_ID, new_account.owner, spl_token_mint_address, user2_public_key,) )
transaction = Transaction(fee_payer=Main_wallet.pubkey(), recent_blockhash=recent_blockhash).add(initialize_instruction)
transaction.sign(Main_wallet, kp)
tx_signature = client.send_transaction(transaction)
print(f"Transaction signature: {tx_signature}")
you know how to interact with Raydium?
you know how to interact with Raydium?
I have not tried doing that, no. @daanrod
If you don't mind helping I'm stuck here with SignerError: keypair-pubkey mismatch and tried and checked almost everything IDK am I doing something wrong or why this issue persist
from solders.account import Account from solana.rpc.api import Client from solana.transaction import Transaction from spl.token.constants import TOKEN_PROGRAM_ID from spl.token.instructions import initialize_account, InitializeAccountParams from solders.pubkey import Pubkey from solana.blockhash import Hash kp = Keypair()
from solana.rpc.api import Client from solana.blockhash import Hash from solders.null_signer import NullSigner
recent_blockhash = client.get_latest_blockhash().value.blockhash
print(f"Most recent blockhash: {recent_blockhash}")
user2_public_key = kp.pubkey() spl_token_mint_address = Pubkey.from_string(Mint_Address["usdt"])
new_account = Account(lamports=100000, data=b"sys_user2", owner=kp.pubkey())
initialize_instruction = initialize_account(InitializeAccountParams( TOKEN_PROGRAM_ID, new_account.owner, spl_token_mint_address, user2_public_key,) )
transaction = Transaction(fee_payer=Main_wallet.pubkey(), recent_blockhash=recent_blockhash).add(initialize_instruction)
transaction.sign(Main_wallet, kp)
tx_signature = client.send_transaction(transaction)
print(f"Transaction signature: {tx_signature}")
I'm not so sure what your problem is exactly, but looking at the code these are the things I noticed.
initialize_instruction = initialize_account(InitializeAccountParams(
TOKEN_PROGRAM_ID,
new_account.owner, #new_account_owner variable not set previously but being used
spl_token_mint_address,
user2_public_key,)
)
transaction = Transaction(fee_payer=Main_wallet.pubkey(), recent_blockhash=recent_blockhash).add(initialize_instruction) #Main_wallet was not set previously before use
Also, try using the Keypair in the Transaction()
rather than the pubkey
If you have already found a solution to this, then that's fine.
@moonlightnexus
Follow up @moonlightnexus
You set kp = Keypair()
Meaning it is not the Keypair of any wallet. It is just a class/function on its own, yet you are using it to sign a transaction: transaction.sign(Main_wallet, kp)
You need the actual Keypair value to sign a transaction. Something along the lines of Main_wallet.Keypair()
(if i remember correctly.
Kindly check this @daanrod Possible way of interacting directly with Raydium
To assist every newbie, here is a simple implementation to get you started with the basic aspects of the solana-py library