I use a ready-made code in Algorand, but when I try to run it with my private key and my address I get this exception: urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>
Thanks for the help!
The code
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')))
This error indicates that no Algorand node is running and accessible via
http://localhost:4001
.First check that you are running a node successfully (and on the same machine as the one used to run the Python script). If you are using sandbox, you can run
./sandbox status
to check sandbox status. It should look like:You can also check if no firewall is blocking anything by running
Finally, you can switch to use API services instead of a localhost node. See https://developer.algorand.org/ecosystem-projects/?tags=api-services