michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
1.02k stars 262 forks source link

Weird behavior in Dev-net and Test-net when sending transactions #204

Closed aleixisp closed 2 years ago

aleixisp commented 2 years ago

In Dev-net and test-net, some transactions fail with the following error: Failed attempt 6: {'code': -32002, 'message': 'Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.', 'data': {'accounts': None, 'err': 'AccountNotFound', 'logs': []}}

Even though there is plenty of funds in the account (i.e. 8Edpg93higHXM7f6eBHXfNGYNKae46wXkgUhdvADwfx8) My idea is to create an NFT, however sometimes the transaction goes through and the NFT is created, other times I get the error stated above. Is this an issue other people are facing? Is there any way to mitigate it in both environments? does main-net suffer from the same? or do I have anything set up wrong?

Currently using metaplex SDK as well (with changes to make it compatible with the current version of Solana-py)

In order to mitigate this is by skip preflight. What's the difference between sending it and preflight, I thought they were under the same framework.

Thanks, Aleix L.

michaelhly commented 2 years ago

Can you provide relevant snippets of code/script?

aleixisp commented 2 years ago
# Currently using metaplex Python SDK
"""https://github.com/metaplex-foundation/python-api"""

from solana.rpc.api import Client

solana_rcp_client = Client(
        endpoint=endpoint,
        commitment=Finalized,
        blockhash_cache=True
    )

"""Initialize Token-init, Metadata-init transaction Solana."""
transaction, signers = \
    deploy_token(
        client=solana_rcp_client,
        source_account=payer_account,
        name=payload['name'],
        symbol=payload['symbol']
    )

"""Execute Transaction to Solana."""
response = execute(
    client=solana_rcp_client,
    tx=transaction,
    signers=signers,
    skip_confirmation=False,
    skip_preflight=True
)
print(response)

where deploy_token and execute are methods from metaplex-python-sdk

crypt0miester commented 2 years ago
# Currently using metaplex Python SDK
"""https://github.com/metaplex-foundation/python-api"""

from solana.rpc.api import Client

solana_rcp_client = Client(
        endpoint=endpoint,
        commitment=Finalized,
        blockhash_cache=True
    )

"""Initialize Token-init, Metadata-init transaction Solana."""
transaction, signers = \
    deploy_token(
        client=solana_rcp_client,
        source_account=payer_account,
        name=payload['name'],
        symbol=payload['symbol']
    )

"""Execute Transaction to Solana."""
response = execute(
    client=solana_rcp_client,
    tx=transaction,
    signers=signers,
    skip_confirmation=False,
    skip_preflight=True
)
print(response)

where deploy_token and execute are methods from metaplex-python-sdk

did you request airdrop to payer_account prior to execution?

double check if it really has funds. what you could do is run the tests in metaplex/python-api. it should work as intended.