I'm trying to use Magic Eden API and solana-py to buy an NFT for the listed price. I'm using the instructins/buy_now
endpoint to do that. I get an error when trying to buy the NFT. Have been trying to fix that for a few weeks, and I still can't. The part of the code for signing the TX:
account_sign = Keypair.from_secret_key(b58decode("xxxxxx"))
tx_signed = data['txSigned']
txn = Transaction.deserialize(bytes(tx_signed['data']))
txn.sign(account_sign)
await solana_client.send_raw_transaction(txn.serialize())
My error:
sign error: {'code': -32002, 'message': 'Transaction simulation failed: Error processing Instruction 2: custom program error: 0x7d3', 'data': {'accounts': None, 'err': {'InstructionError': [2, {'Custom': 2003}]}, 'logs': ['Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K invoke [1]', 'Program log: Instruction: Deposit', 'Program 11111111111111111111111111111111 invoke [2]', 'Program 11111111111111111111111111111111 success', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K consumed 9465 of 600000 compute units', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K success', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K invoke [1]', 'Program log: Instruction: Buy', 'Program 11111111111111111111111111111111 invoke [2]', 'Program 11111111111111111111111111111111 success', 'Program log: {"price":32000000,"buyer_expiry":0}', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K consumed 26365 of 590535 compute units','Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K success', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K invoke [1]', 'Program log: Instruction: ExecuteSale', 'Program log: AnchorError caused by account: seller_trade_state. Error Code: ConstraintRaw. Error Number: 2003. Error Message: A raw constraint was violated.', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K consumed 23877 of 564170 compute units', 'Program M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K failed: custom program error: 0x7d3'], 'unitsConsumed': 35830}}
The URL I'm sending to the ME API:
https://api-mainnet.magiceden.dev/v2/instructions/buy_now?buyer=ADsE28NEc1hD9ZjocLBGrwARCuK5NTSi7HtwUktNbXD1&seller=D2AxugHdccsxy9KD7sUmZjJnvdgadYw4kptwDKaQPyQ&auctionHouseAddress=E8cU1WiRWjanGxmn96ewBgk9vPTcL6AEZ1t6F6fkgUWe&tokenMint=DefXNy9qma1CgEjFRbbaPjPdFAS1VuEwTY1Lt631zHqC&tokenATA=8LeRMLpcNbvewqNUs22yeP8cNvzod3C5ictURqT722Yj&price=0.01&sellerReferral=autMW8SgBkVYeBgqYiTuJZnkvDZMVU2MHJh9Jh7CSQ2&sellerExpiry=0
ME responds with something similar to this:
{
"tx":
{
"type": "Buffer",
"data":
[
2,
1,
9,
.....
]
},
"txSigned":
{
"type": "Buffer",
"data":
[
2,
0,
0,
.....
]
}
}
What am I doing wrong? Really need your help.