I got some error like that
sometimes it is work well but sometimes it gets that error
I tried try, except code but it doesnt work.
note: run with 'RUST_BACKTRACE=1 environment variable to display a backtrace Traceback (most recent call last): File "main.py", line 54, in asyncio.run (start_buy (payer, valance, client)) File " /us/local/lib/python3.7/asyncio/runners.py", line 43, in run return loop.run_until_complete (main) File "/us/local/lib/python3.7/asyncio/base_events.py", line 566, in run_until_complete self.run_forever () File "/us/local/lib/python3.7/asyncio/base_events-py", line 534, in run_ forever self._run_once () File " /us/local/lib/python3.7/asyncio/base_events.py", line 1771, in _run_once handle. _run () File "/usr/local/lib/python3.7/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "main.py", line 20, in start_buy buy_transaction=await buy (client, manny, payer, amount-0.02) #Enter amount of sol you wish to saand File "/workspace/contrader /buy_swap.py", line 80, in buy E501 line too long (91 > 79 characters) | visual indent txn = solana_client.send_transaction (swap_tx, payer, Wsol_account_keyPair) File "/usr/local/lib/python3.7/site-packages/solana/rpc/api.py",line1067,insend_transaction txn_resp = self.send_raw_transaction(txn.serialize() , opts=opts_to_use) File "/us/local/lib/python3.7/site-packages/solana/rpc/api.py",line992,insend_raw_transaction resp = self._provider.make_request (body, SendTransactionResp) File " /us/local/lib/python3.7/site-packages/solana/exceptions.py", line 43, in argument_decorator return func (*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/solana/rpc/providers/http.py",line49,in make_request return _parse_raw(raw, parser=parser) File "/usr/local/lib/python3.7/site-packages/solana/rpc/providers/core.py",line95,in_parse_raw parsed = parser. from_json (raw) # type: ignore pyo3_runtime. PanicException: called 'Result: :unwrap() on an 'Err' value: Error ("missing field 'data'", line: 0, column: 0)
I saw simillar question here here
but it is not work on me.
instructions_swap = make_swap_instruction(amount_in,
WSOL_token_account,
swap_associated_token_address,
pool_keys,
mint,
solana_client,
payer,
True)
params = CloseAccountParams(account=WSOL_token_account, dest=payer.pubkey(), owner=payer.pubkey(),
program_id=TOKEN_PROGRAM_ID)
closeAcc = (close_account(params))
if swap_token_account_Instructions != None:
swap_tx.add(swap_token_account_Instructions)
#compute unit price and comute unit limit gauge your gas fees more explanations on how to calculate in a future article
swap_tx.add(instructions_swap,set_compute_unit_price(25_232),set_compute_unit_limit(2000337),closeAcc)
print(swap_tx, payer, Wsol_account_keyPair)
txn = solana_client.send_transaction(swap_tx, payer,Wsol_account_keyPair)
error started here and in make_swap_instruction
keys = [
AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["amm_id"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["authority"], is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["open_orders"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["target_orders"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["base_vault"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["quote_vault"], is_signer=False, is_writable=True),
AccountMeta(pubkey=SERUM_PROGRAM_ID, is_signer=False, is_writable=False),
AccountMeta(pubkey=accounts["market_id"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["bids"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["asks"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["event_queue"], is_signer=False, is_writable=Ture),
AccountMeta(pubkey=accounts["market_base_vault"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["market_quote_vault"], is_signer=False, is_writable=True),
AccountMeta(pubkey=accounts["market_authority"], is_signer=False, is_writable=False),
AccountMeta(pubkey=token_account_in, is_signer=False, is_writable=True), #UserSourceTokenAccount
AccountMeta(pubkey=token_account_out, is_signer=False, is_writable=True), #UserDestTokenAccount
AccountMeta(pubkey=owner.pubkey(), is_signer=True, is_writable=False) #UserOwner
]
data = SWAP_LAYOUT.build(
dict(
instruction=9,
amount_in=int(amount_in),
min_amount_out=calculate_min_amount_out(amount_in, 0.05, buy)
)
)
return Instruction(AMM_PROGRAM_ID, data, keys)
What can I do for fix it?