Hi all,
I am working on a modified voting architecture using Choice Coin on TestNet. My intention is to generate a simplified voting model, where a user inputs a Boolean value 1 or 0. If the user inputs a 1, then the vote function sends 1 Choice to a vote address, which aggregates all the votes. Below is the code block I am hacking with and here is a LINK to the full code on GitHub.
def vote():
voter = input(str("Vote 0 for zero and vote 1 for one:"))
params = algod_client.suggested_params()
if voter is str('1'):
# send one choice to address
amount = 1
txn = AssetTransferTxn(sender=creator_address, sp=params, receiver=vote_address, amt=amount, index=asset_id)
signature = transaction.sign(voter_phrase)
algod_client.send_transaction(signature)
final = transaction.get_txid()
return True, final
print ("Thanks for voting for one.")
else:
# send zero choice to address
print ("Thanks for voting for zero.")
vote()
Here, the function asks a voter for a 0 or 1 vote. If the vote is a 1, then it intends to send one Choice from the voter_address
to the vote_address
. But, I am consistently getting a network error, which is below.
Vote 0 for zero and vote 1 for one:1
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 82, in algod_request
resp = urlopen(req)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 531, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Basic_Vote.py", line 44, in <module>
vote()
File "Basic_Vote.py", line 31, in vote
params = algod_client.suggested_params()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 314, in suggested_params
res = self.algod_request("GET", req, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 89, in algod_request
raise error.AlgodHTTPError(e, code)
algosdk.error.AlgodHTTPError: invalid input: unable to parse base32 digest data 'txid': illegal base32 data at input byte 0
I’d appreciate any help or suggestions on hacking through this problem connecting to the network. I am using the PureStake API to connect, which has resolved similar urlopen
errors for me in the past, but I am not sure this is primarily a urlopen
error. The final line suggests a problem digesting the txid
, but I am not sure how to account for this error output. Thanks in advance!