I’m getting this error while making a transaction
algosdk.error.AlgodHTTPError: TransactionPool.Remember: transaction 76UARSTKLTOOXXHN4ISCVC54UP6DR5H2LORPDVANXWXDPJRCNGWA: overspend <my_acc_address>
# and here's my code
import base64
from algosdk.future import transaction
from algosdk import mnemonic
from algosdk.v2client import algod
from pyteal import *
benefactor_mnemonic = "YOUR-MNEMONICS-HERE"
sender_mnemonic = "YOUR-MNEMONICS-HERE"
algod_address = "http://localhost:4001"
algod_token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
def compile_smart_signature(client, source_code):
compile_response = client.compile(source_code)
return compile_response['result'], compile_response['hash']
def get_private_key_from_mnemonic(mn) :
private_key = mnemonic.to_private_key(mn)
return private_key
def payment_transaction(creator_mnemonic, amt, rcv, algod_client)->dict:
params = algod_client.suggested_params()
add = mnemonic.to_public_key(creator_mnemonic)
key = mnemonic.to_private_key(creator_mnemonic)
unsigned_txn = transaction.PaymentTxn(add, params, rcv, amt)
signed = unsigned_txn.sign(key)
tx_id = algod_client.send_transaction(signed)
print("txn id:", tx_id)
pmtx = transaction.wait_for_confirmation(algod_client, tx_id , 5)
return pmtx
def lsig_payment_txn(escrowProg, escrow_address, amt, rcv, algod_client):
params = algod_client.suggested_params()
unsigned_txn = transaction.PaymentTxn(escrow_address, params, rcv, amt)
encodedProg = escrowProg.encode()
program = base64.decodebytes(encodedProg)
lsig = transaction.LogicSig(program)
stxn = transaction.LogicSigTransaction(unsigned_txn, lsig)
tx_id = algod_client.send_transaction(stxn)
print("txn id:", tx_id)
pmtx = transaction.wait_for_confirmation(algod_client, tx_id, 10)
return pmtx
def donation_escrow(benefactor):
Fee = Int(1000)
program = And(
Txn.type_enum() == TxnType.Payment,
Txn.fee() <= Fee,
Txn.receiver() == Addr(benefactor),
Global.group_size() == Int(1),
Txn.rekey_to() == Global.zero_address()
)
return compileTeal(program, Mode.Signature, version=5)
def main() :
algod_client = algod.AlgodClient(algod_token, algod_address)
receiver_public_key = mnemonic.to_public_key(benefactor_mnemonic)
print("--------------------------------------------")
print("Compiling Donation Smart Signature......")
stateless_program_teal = donation_escrow(receiver_public_key)
escrow_result, escrow_address= compile_smart_signature(algod_client, stateless_program_teal)
print("Program:", escrow_result)
print("hash: ", escrow_address)
print("--------------------------------------------")
print("Activating Donation Smart Signature......")
amt = 4001000
payment_transaction(sender_mnemonic, amt, escrow_address, algod_client)
print("--------------------------------------------")
print("Withdraw from Donation Smart Signature......")
withdrawal_amt = 1000000
lsig_payment_txn(escrow_result, escrow_address, withdrawal_amt, receiver_public_key, algod_client)
main()