Here is my error message
It looks as if theres an error in one of the SDK files because its showing errors from lines thats not present in my code
Traceback (most recent call last):
File "C:\Users\New Age\PycharmProjects\Pure Python\venv\lib\site-packages\algosdk\v2client\algod.py", line 82, in algod_request
resp = urlopen(req)
File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 649, in http_error_default
Here is my code (my private key is shared, its fine its just for learning purposes)
import json
import base64
from algosdk import account, mnemonic, constants
from algosdk.v2client import algod
from algosdk.future import transaction
def generate_algorand_keypair():
private_key, address = account.generate_account()
print("My address: {}".format(address))
print("My private key: {}".format(private_key))
print("My passphrase: {}".format(mnemonic.from_private_key(private_key)))
#Write down the address, private key, and the passphrase for later usage
#generate_algorand_keypair()
def first_transaction_example(private_key, my_address):
algod_address = "http://localhost:4001"
algod_token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
algod_client = algod.AlgodClient(algod_token, algod_address)
print("My address: {}".format(my_address))
account_info = algod_client.account_info(my_address)
print("Account balance: {} microAlgos".format(account_info.get('amount')))
# build transaction
params = algod_client.suggested_params()
# comment out the next two (2) lines to use suggested fees
params.flat_fee = constants.MIN_TXN_FEE
params.fee = 1000
receiver = "HZ57J3K46JIJXILONBBZOHX6BKPXEM2VVXNRFSUED6DKFD5ZD24PMJ3MVA"
note = "Hello World".encode()
unsigned_txn = transaction.PaymentTxn(my_address, params, receiver, 1000000, None, note)
# sign transaction
signed_txn = unsigned_txn.sign(private_key)
# submit transaction
txid = algod_client.send_transaction(signed_txn)
print("Signed transaction with txID: {}".format(txid))
# wait for confirmation
try:
confirmed_txn = transaction.wait_for_confirmation(algod_client, txid, 4)
except Exception as err:
print(err)
return
print("Transaction information: {}".format(
json.dumps(confirmed_txn, indent=4)))
print("Decoded note: {}".format(base64.b64decode(
confirmed_txn["txn"]["txn"]["note"]).decode()))
print("Starting Account balance: {} microAlgos".format(account_info.get('amount')) )
print("Amount transfered: {} microAlgos".format(amount) )
print("Fee: {} microAlgos".format(params.fee) )
account_info = algod_client.account_info(my_address)
print("Final Account balance: {} microAlgos".format(account_info.get('amount')) + "\n")
#replace private_key and my_address with your private key and your address
first_transaction_example("Kp91CqffmHaYXjTUHreHeugg6np1e61HMIxr2p3MZAuQ8PkgIG461Mif0uES4TQJXed5n6Xp3uCIxNlKQCghDQ==", "SDYPSIBANY5NJSE72LQRFYJUBFO6O6M7UXU55YEIYTMUUQBIEEGRITJWWU")
what is the error?