-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBV2.py
52 lines (46 loc) · 1.79 KB
/
BV2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright Fortior Blockchain, LLLP 2021
# Apache License
# Imports
from algosdk.v2client import algod
from algosdk import account, encoding, mnemonic, transaction
from algosdk.future.transaction import AssetConfigTxn, AssetTransferTxn, PaymentTxn, write_to_file
from algosdk import mnemonic
# Put Algod Client address here
algod_address = "https://testnet-algorand.api.purestake.io/ps2"
# Put Algod Token here
algod_token = ""
headers = {"X-API-Key": algod_token }
# Initializes client for node.
algod_client = algod.AlgodClient(algod_token,algod_address,headers)
# Choice Asset ID.
asset_id = 42771692
# Create new address from scratch
# Variational where each option has an address
# VOID TEST ADDRESS
voter_address = ""
voter_phrase = mnemonic.to_private_key("")
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 = 100
vote_address = ""
transaction = AssetTransferTxn(sender=voter_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()
print ("Thanks for voting for one.")
print(final)
else:
# do not send one choice to address
amount = 100
vote_address = ""
transaction = AssetTransferTxn(sender=voter_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()
print ("Thanks for voting for zero.")
print(final)
vote()
# TXID: EP6OMX2E7CMCXEWSZP6CZLRVCPBSQSM4G2AWL23U7J22BMTMOD5Q