-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransaction.py
73 lines (51 loc) · 2.17 KB
/
Transaction.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from algosdk import algod, mnemonic, transaction, account
# from flask import Flask
# from flask_cors import CORS
# app = Flask(__name__)
# cors = CORS(app)
# @app.route('/')
# def signTransaction():
# return (txid)
# if __name__ == "__main__":
# app.run(host="localhost",port="8081")
# passphrase = "like allow recall gesture subject ready pony bracket gas wealth nephew unfold hedgehog donor lion husband frequent boring cloth thrive razor domain term absorb similar"
# acl = algod.AlgodClient("H9IknTatc8DgHA3kOa3m4YyCvQCOZV7xUtWvq640", "https://testnet-algorand.api.purestake.io/ps1")
# # convert passphrase to secret key
# sk = mnemonic.to_private_key(passphrase)
# # get suggested parameters
# params = acl.suggested_params()
# gen = params["genesisID"]
# gh = params["genesishashb64"]
# last_round = params["lastRound"]
# fee = params["fee"]
# # Set other parameters
# amount = 10
# note = "Some Text".encode()
# receiver = "MSVOSPBXU5NFII4AHOM3CH4NLF6GFAXNGC4DWSC6E33VWOI4DNZ7DC2JAQ"
# # create the transaction
# txn = transaction.PaymentTxn(account.address_from_private_key(sk), fee, last_round, last_round+1000, gh, receiver, amount, note=note)
# # sign it
# stx = txn.sign(sk)
# # send it
# txid = acl.send_transaction(stx)
from algosdk import algod, mnemonic, transaction, account
passphrase = "like allow recall gesture subject ready pony bracket gas wealth nephew unfold hedgehog donor lion husband frequent boring cloth thrive razor domain term absorb similar"
acl = algod.AlgodClient("ef920e2e7e002953f4b29a8af720efe8e4ecc75ff102b165e0472834b25832c1", "http://hackathon.algodev.network:9100/")
# convert passphrase to secret key
sk = mnemonic.to_private_key(passphrase)
# get suggested parameters
params = acl.suggested_params()
gen = params["genesisID"]
gh = params["genesishashb64"]
last_round = params["lastRound"]
fee = params["fee"]
# Set other parameters
amount = 10
note = "Special Dish".encode()
receiver = "receiver Algorand Address"
# create the transaction
txn = transaction.PaymentTxn(account.address_from_private_key(sk), fee, last_round, last_round+1000, gh, receiver, amount, note=note)
# sign it
stx = txn.sign(sk)
# send it
txid = acl.send_transaction(stx)