algosdk.error.AlgodHTTPError: This Error Occurs when i try to transfer Algos from one account to another

I got this error when trying to transfer Algos from one account to another. I am using Flask Python to build my interface.

Can I get help where I have got it wrong?

Hi @Mosuhli if you read the error correctly it says account 1 tried to “overspend”, i.e the account from which you are trying to transfer algos does not have sufficient algo balance, fund the account from algorand testnet faucet, and then try it.

1 Like

Hi @AnishRane the account that i am transfering to has 20 algos while the one i am using to transfer has 30 algos. Please take a look at my code:

Is this link helpful?

Hey @Handa When i tried using PureStake i get this error:

I just take the last full code as it is and try to test with but change some few lines:

from algosdk import algod
from algosdk import mnemonic
from algosdk import transaction


def send():
    # fund these 2 accounts with some initial algo via the dispenser:
    # https://bank.testnet.algorand.network/
    # address a: I6Z3SSULKBUH2FH5L3LMCUM63G5FCNQIYOYWZBM4V4CZTFH23M3FRV7GXA
    # address b: 7YEPQKFVKJKFQJJVU5XMS22RZL3NSB2WLYZQO5HMWABUNF4MBFSRIMDB5Q
    mnemonic_secret = "manual inject across monkey cereal yellow coffee arrange primary topic express increase figure green wild resemble initial certain cupboard income box muscle square able purchase"
    account_a_private_key = mnemonic.to_private_key(mnemonic_secret)
    account_a = mnemonic.to_public_key(mnemonic_secret)
    account_b = '2FHGMBI3BD324ATTE6XEVKUTADV57DR63JVSX2CSG7WAOSFSGIQYATWZMY'

    # Setup client with PureStake key
    purestake_key = 'efNbPeyBYRHznhB755BR7rrB642virrrr4XUYp8I9egeqfFUf'
    endpoint_address = 'https://betanet-algorand.api.purestake.io/idx2'
    purestake_header = {'X-Api-key': purestake_key}
    acl = algod.AlgodClient(purestake_key, endpoint_address,
                            headers=purestake_header)

    # get suggested parameters
    params = acl.suggested_params()
    gen_hash = params["genesishashb64"]
    first_valid_round = params["lastRound"]
    last_valid_round = first_valid_round + 1000
    tx_fee = params["fee"]
    tx_amount = 10000

    # Create and sign transaction
    tx = transaction.PaymentTxn(account_a, tx_fee, first_valid_round,
                                last_valid_round, gen_hash, account_b, tx_amount)
    signed_tx = tx.sign(account_a_private_key)

    try:
        # Send the transaction
        print("Sending " + str(tx_amount) + " microalgo from " +
            account_a + " to " + account_b + "...", end='', flush=True)
        # note that the PureStake api requires the content type for the following call to be set to application/x-binary
        tx_confirm = acl.send_transaction(
            signed_tx, headers={'content-type': 'application/x-binary'})
        # wait 2 blocks to make sure our tx has been committed
        acl.status_after_block(first_valid_round + 2)

        print("Done.")
        print("Sent " + str(tx_amount) +
            " microalgo in transaction: " + str(tx_confirm))
        print("")

        # Query resulting balances
        result_a = acl.account_info(account_a)
        result_b = acl.account_info(account_b)

        print("Resulting balances")
        print(result_a["address"] + ": " + str(result_a["amount"]) + " microalgo")
        print(result_b["address"] + ": " + str(result_b["amount"]) + " microalgo")

    except Exception as e:
        print(e)

Changed lines:

    mnemonic_secret = "manual inject across monkey cereal yellow coffee arrange primary topic express increase figure green wild resemble initial certain cupboard income box muscle square able purchase"
    
    account_b = '2FHGMBI3BD324ATTE6XEVKUTADV57DR63JVSX2CSG7WAOSFSGIQYATWZMY'

    purestake_key = 'efNbPeyBYRHznhB755BR7rrB642virrrr4XUYp8I9egeqfFUf'
    endpoint_address = 'https://betanet-algorand.api.purestake.io/idx2'

If a block explorer shows the correct balance but your node rejects as you show above because of balance = 0, this usually means that:

  1. either you’re connected to the wrong network
  2. or your node is not synced (check with goal node status)

Now regarding your issue with PureStake, have you tried: PureStake Developer Portal
Concretely, you are using the wrong endpoint:

    endpoint_address = 'https://testnet-algorand.api.purestake.io/ps2'

2 issues:

  1. you were on betanet instead of testnet
  2. you were using the indexer endpoint (idx2) instead of the algod endpoint (ps2)

Note: do not write your API key publicly as this will allow anyone to abuse it…

@fabrice the API key already edited, its not the original one.