-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from algosdk import algod | ||
import csv | ||
from algosdk.v2client import algod, indexer | ||
from algosdk import mnemonic | ||
from algosdk.future import transaction | ||
|
||
CHOICE_ID = 297995609 | ||
ALGOD_ADDRESS = "https://node.algoexplorerapi.io" | ||
INDEXER_ADDRESS = "https://algoindexer.algoexplorerapi.io" | ||
ALGOD_TOKEN = "" | ||
ALGOD_CLIENT = algod.AlgodClient(ALGOD_TOKEN, ALGOD_ADDRESS, {"X-API-Key": ""}) | ||
INDEXER_CLIENT = indexer.IndexerClient(ALGOD_TOKEN, INDEXER_ADDRESS, {"X-API-Key": ""}) | ||
# The address of the account you're sending with | ||
SENDER_ADDRESS = "" | ||
# The mnemonic of the address you're sending with | ||
SENDER_MNEMONIC = "" | ||
|
||
|
||
def send_choice(to: str, amount: float, multiplier: float) -> bool: | ||
suggested_params = ALGOD_CLIENT.suggested_params() | ||
amount = int(amount * 100 * multiplier) | ||
unsigned_txn = transaction.AssetTransferTxn( | ||
sender=SENDER_ADDRESS, | ||
sp=suggested_params, | ||
receiver=to, | ||
amt=amount, | ||
index=CHOICE_ID, | ||
) | ||
try: | ||
signed_txn = unsigned_txn.sign(mnemonic.to_private_key(SENDER_MNEMONIC)) | ||
txid = ALGOD_CLIENT.send_transaction(signed_txn) | ||
print(txid) | ||
return True | ||
except: | ||
return False | ||
|
||
|
||
with open('../myFile.csv', newline='') as f: | ||
reader = csv.reader(f) | ||
data = list(reader) | ||
|
||
for row in data[1:]: | ||
sending_amount = float(row[-1]) | ||
send_choice(to=row[0], amount=sending_amount, multiplier=0.01) |