passphrase="extra hungry share oblige water equip slender surround quality jeans harbor liquid trade labor rapid polar length awake deposit pass success soul night absorb river"
passphrase=" maze huge bronze student orphan news weasel cable column chaos project friend prefer demand bind frame total muffin exist acid unfold toddler era abstract soap"
KNRTFTRSTNTG7AC5GUJFEWMAF3LMDK4IFIVN5O72PQXF3U5X6Z26DNJ4SQ
passphrase ="long bench click shift pact lizard explain violin pizza planet left speed glow pencil endless farm taste sense gauge angry demand whip broom able machine"(su)
UW2GFXFO7GLP5Z2PAI3ALODDXEVPTXQSZZ6AIYHPNJUMZ4P52OE4QPF7BE
passphrase ="acid later donor solve trigger farm profit mutual never carry certain razor neither party dolphin suffer poet hawk argue frame alien sibling hotel absorb rubber"(bab)
D2PT3PFCLRUASHE7OHHHNFSZIXWBEDWSOEDTL5TVYSWDKW2SFFHSL6DAY4
passphras="book adult apart security sign bid acid trend kitten stove volcano coconut before exhaust calm apart truck inspire hair now alien across water ability key"(babloo1)
RB232H7I6YX34CX3EIICYPHT2A64GAQLZC7YCHNKPWGB4GJMADWBGZBSMA
passphrase="develop menu torch front wish stem ski again general where rule castle virus expire suit minimum duty recycle seat chunk advice imitate journey ability calm" passphrase="polar curtain tenant usual boy hamster arctic design flock ride soul good smoke frown buzz potato outside put either shadow visa rapid holiday absent brain" passphrase = "canoe sustain edge prepare burden imitate swamp pepper fox decide weather banner remain viable connect sniff unaware arrange peanut matter young mule genius above stumble"
=======================================================================================================================================================================================================from pyteal import * vtc contract
def clear_app(): return Approve()
def approveapp(): oncreate = Seq( [ App.globalPut(Bytes("owner"), Global.creatoraddress()), App.globalPut(Bytes("taskid"), Txn.applicationargs[0] ), App.globalPut(Bytes("clientaddress"), Txn.accounts[1]), App.globalPut(Bytes("workeraddress"), Txn.accounts[2]), App.globalPut(Bytes("reviewaddress"), Global.creatoraddress()), App.globalPut(Bytes("noofAlgos"),Txn.applicationargs[1]), Approve(), ])
on_update = Seq(
Assert(Txn.sender()== App.globalGet(Bytes("owner"))),
Approve(),
)
on_delete = Seq(
Assert(Txn.sender()== App.globalGet(Bytes("owner"))),
Approve(),
)
on_optin = Seq(Approve())
on_closeout = Seq(
Reject()
)
set_reviewer=Seq(
Assert(Txn.sender() == App.globalGet(Bytes("owner"))),
App.globalPut(Bytes("review_address"), Txn.accounts[1]),
Approve(),
)
# verification_task_completed = Seq([
# Assert(
# And(
# Or(
# Txn.sender() == App.globalGet(Bytes("review_address")),
# Txn.sender() == App.globalGet(Bytes("owner")),
# ),
# Txn.accounts[2]==App.globalGet(Bytes("worker_address")),
# Global.group_size() == Int(1),
# Txn.rekey_to() == Global.zero_address(),
# )
# ),
# InnerTxnBuilder.Begin(),
# InnerTxnBuilder.SetFields({
# TxnField.type_enum: TxnType.Payment,
# TxnField.receiver: Txn.accounts[2],
# TxnField.amount:(Btoi(Txn.application_args[1]))*(Btoi(App.globalGet(Bytes("no_of_Algos"))))/Int(100) - Global.min_balance()-(Btoi(App.globalGet(Bytes("no_of_Algos")))*Int(5) / Int(100)),
# }),
# InnerTxnBuilder.Submit(),
# InnerTxnBuilder.Begin(),
# InnerTxnBuilder.SetFields({
# TxnField.type_enum: TxnType.Payment,
# TxnField.receiver: Global.creator_address(),
# TxnField.amount: ( Btoi(App.globalGet(Bytes("no_of_Algos")))*Int(5) / Int(100)),
# TxnField.close_remainder_to:Txn.accounts[1],
# }),
# InnerTxnBuilder.Submit(),
# Approve(),
# ])
verification_task_completed = Seq([
Assert(
And(
Or(
Txn.sender() == App.globalGet(Bytes("review_address")),
Txn.sender() == App.globalGet(Bytes("owner")),
),
Txn.accounts[1]==App.globalGet(Bytes("worker_address")),
Global.group_size() == Int(1),
Txn.rekey_to() == Global.zero_address(),
)
),
If(Txn.application_args[1]==(Bytes("algos")))
.Then(
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.Payment,
TxnField.receiver: Txn.accounts[1], # Worker Address
TxnField.amount: ((Btoi(App.globalGet(Bytes("no_of_Algos")))) -( Global.min_balance() + ((Btoi(App.globalGet(Bytes("no_of_Algos")))*(Int(5)) / Int(100))))),
}),
InnerTxnBuilder.Submit(),
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.Payment,
TxnField.receiver: Global.creator_address(), # SC OWNER
TxnField.amount: (Btoi(App.globalGet(Bytes("no_of_Algos")))*(Int(5) / Int(100))),
TxnField.close_remainder_to:Txn.accounts[1], # Client Address
}),
InnerTxnBuilder.Submit(),
)
.Else(
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.Payment,
TxnField.close_remainder_to:Global.creator_address(),
}),
InnerTxnBuilder.Submit(),
),
Approve(),
])
verification_task_not_completed = Seq([
Assert(
And(
Or(
Txn.sender() == App.globalGet(Bytes("review_address")),
Txn.sender() == App.globalGet(Bytes("owner")),
),
Txn.accounts[1]==App.globalGet(Bytes("client_address")),
Global.group_size() == Int(1),
Txn.rekey_to() == Global.zero_address(),
)
),
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.Payment,
TxnField.receiver: Txn.accounts[1],
TxnField.amount: Btoi(App.globalGet(Bytes("no_of_Algos")))-Global.min_balance(),
TxnField.close_remainder_to:Global.creator_address(),
}),
InnerTxnBuilder.Submit(),
Approve(),
]
)
optin = Seq([
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.AssetTransfer,
# TxnField.asset_sender: Global.current_application_address(),
TxnField.asset_receiver: Global.current_application_address(),
TxnField.asset_amount: Int(0),
TxnField.xfer_asset : Txn.assets[0],
}),
InnerTxnBuilder.Submit(),
Approve(),
])
return Cond(
[Txn.application_id() == Int(0), on_create],
[Txn.on_completion() == OnComplete.UpdateApplication, on_update],
[Txn.on_completion() == OnComplete.DeleteApplication, on_delete],
[Txn.on_completion() == OnComplete.OptIn,on_optin],
[Txn.on_completion() == OnComplete.CloseOut, on_closeout],
[Txn.application_args[0] == Bytes("add_reviewer"),set_reviewer],
[Txn.application_args[0] == Bytes("vtc"),verification_task_completed],
[Txn.application_args[0] == Bytes("vtnc"),verification_task_not_completed],
[Txn.application_args[0] == Bytes("optin"),optin],
)
with open("approve.teal","w") as f: approveteal= compileTeal(approveapp(), Mode.Application, version=5) f.write(approve_teal)
with open("clear.teal","w") as f: clearteal= compileTeal(clearapp(), Mode.Application, version=5)
import base64 from algosdk import account, mnemonic from algosdk.v2client import algod from algosdk.future import transaction from algosdk.logic import getapplicationaddress import base64
algodaddress = "https://testnet-api.algonode.cloud" algodtoken = "" algodclient = algod.AlgodClient(algodtoken, algod_address)
def deploy(ownerpassphrase,taskid,noofalgos,clientaddress,workeraddress): owner = mnemonic.topublickey(ownerpassphrase) privatekey = mnemonic.toprivatekey(ownerpassphrase) params = algodclient.suggested_params()
local_ints = 0
local_bytes = 0
global_ints = 1
global_bytes = 6
global_schema = transaction.StateSchema(global_ints, global_bytes)
local_schema = transaction.StateSchema(local_ints, local_bytes)
with open("approve.teal","r") as f:
approval_program =f.read()
with open("clear.teal","r") as f:
clear_state_program =f.read()
app_response = algod_client.compile(approval_program)
rej_response = algod_client.compile(clear_state_program)
on_complete = transaction.OnComplete.NoOpOC.real
txn = transaction.ApplicationCreateTxn(
owner,
params,
on_complete,
base64.b64decode(app_response["result"]),
base64.b64decode(rej_response["result"]),
global_schema,
local_schema,
app_args=[task_id,no_of_algos],
accounts=[client_address,worker_address]
)
# sign transaction
signed_txn = txn.sign(private_key)
txId = signed_txn.transaction.get_txid()
# send transaction
algod_client.send_transactions([signed_txn])
# wait for confirmation
try:
transaction_response = transaction.wait_for_confirmation(algod_client, txId, 1000)
# display results
transaction_response = algod_client.pending_transaction_info(txId)
app_id = transaction_response['application-index']
Contract_Address = get_application_address(app_id)
print("TXID: ", txId)
print("Result confirmed in round: {}".format(transaction_response['confirmed-round']))
print("----------------------------Application Deployed----------------------------")
return {'status':True,'sc_add':Contract_Address,'owner_add':owner,'app_id':app_id}
except Exception as err:
return {'status':False,'ERROR':err}
data=deploy(" maze huge bronze student orphan news weasel cable column chaos project friend prefer demand bind frame total muffin exist acid unfold toddler era abstract soap","task344",5000000,"D2PT3PFCLRUASHE7OHHHNFSZIXWBEDWSOEDTL5TVYSWDKW2SFFHSL6DAY4","UW2GFXFO7GLP5Z2PAI3ALODDXEVPTXQSZZ6AIYHPNJUMZ4P52OE4QPF7BE")
import base64 from algosdk import account, mnemonic from algosdk.v2client import algod from algosdk.future import transaction from algosdk.logic import getapplicationaddress import base64
algodaddress = "https://testnet-api.algonode.cloud" algodtoken = "" algodclient = algod.AlgodClient(algodtoken, algod_address)
def deploy(ownerpassphrase,taskid,noofalgos,clientaddress,workeraddress): owner = mnemonic.topublickey(ownerpassphrase) privatekey = mnemonic.toprivatekey(ownerpassphrase) params = algodclient.suggested_params()
local_ints = 0
local_bytes = 0
global_ints = 1
global_bytes = 6
global_schema = transaction.StateSchema(global_ints, global_bytes)
local_schema = transaction.StateSchema(local_ints, local_bytes)
with open("approve.teal","r") as f:
approval_program =f.read()
with open("clear.teal","r") as f:
clear_state_program =f.read()
app_response = algod_client.compile(approval_program)
rej_response = algod_client.compile(clear_state_program)
on_complete = transaction.OnComplete.NoOpOC.real
txn = transaction.ApplicationCreateTxn(
owner,
params,
on_complete,
base64.b64decode(app_response["result"]),
base64.b64decode(rej_response["result"]),
global_schema,
local_schema,
app_args=[task_id,no_of_algos],
accounts=[client_address,worker_address]
)
# sign transaction
signed_txn = txn.sign(private_key)
txId = signed_txn.transaction.get_txid()
# send transaction
algod_client.send_transactions([signed_txn])
# wait for confirmation
try:
transaction_response = transaction.wait_for_confirmation(algod_client, txId, 1000)
# display results
transaction_response = algod_client.pending_transaction_info(txId)
app_id = transaction_response['application-index']
Contract_Address = get_application_address(app_id)
print("TXID: ", txId)
print("Result confirmed in round: {}".format(transaction_response['confirmed-round']))
print("----------------------------Application Deployed----------------------------")
return {'status':True,'sc_add':Contract_Address,'owner_add':owner,'app_id':app_id}
except Exception as err:
return {'status':False,'ERROR':err}
def payAlgos(appid,passphrase,noofalgos): sender = mnemonic.topublickey(passphrase) privatekey = mnemonic.toprivatekey(passphrase) params = algodclient.suggestedparams() # create unsigned transaction txn = transaction.PaymentTxn( sender, params, amt=noofalgos, receiver=getapplicationaddress(appid), ) # sign transaction signedtxn = txn.sign(privatekey) try: txId = signedtxn.transaction.gettxid() # send transaction txId =algodclient.sendtransactions([signedtxn]) # await confirmation transaction.waitforconfirmation(algodclient, txId,1000) # display results return {'status':True,'Algosdepositedintoapplication_by':sender} except Exception as err: return {'status':False,'ERROR':err}
def setReviewer(appid,passphrase,revieweraddress): sender = mnemonic.topublickey(passphrase) privatekey = mnemonic.toprivatekey(passphrase) params = algodclient.suggestedparams() # create unsigned transaction txn = transaction.ApplicationNoOpTxn( sender, params, index=appid, appargs=["addreviewer"], accounts=[revieweraddress] ) # sign transaction signedtxn = txn.sign(privatekey) try: txId = signedtxn.transaction.gettxid() # send transaction txId =algodclient.sendtransactions([signedtxn]) # await confirmation transaction.waitforconfirmation(algodclient, txId,4) # display results # print("Revieweradded") return {'status': True,'Revieweraddressis':reviewer_address} except Exception as err: return {'status': False,'err':err}
def vtc(appid,passphrase,workeraddress,clientaddress,percentage): sender = mnemonic.topublickey(passphrase) privatekey = mnemonic.toprivatekey(passphrase) params = algodclient.suggestedparams() # create unsigned transaction txn = transaction.ApplicationNoOpTxn( sender, params, index=appid, appargs=["vtc",percentage], accounts=[clientaddress,workeraddress] ## SHOULD GIVE WORKER ADDRESS ONLY ) # sign transaction signedtxn = txn.sign(privatekey) try: txId = signedtxn.transaction.gettxid() # send transaction txId =algodclient.sendtransactions([signedtxn]) # await confirmation transaction.waitforconfirmation(algodclient, txId,4) # display results # print("Revieweradded") return {'status': True,'rewardsentto':workeraddress} except Exception as err: return {'status': False,'err':err}
def vtnc(appid,passphrase,clientaddress): sender = mnemonic.topublickey(passphrase) privatekey = mnemonic.toprivatekey(passphrase) params = algodclient.suggestedparams() # create unsigned transaction txn = transaction.ApplicationNoOpTxn( sender, params, index=appid, appargs=["vtnc"], accounts=[clientaddress] # SHOULD GIVE CLIENT ADD ONLY ) signedtxn = txn.sign(privatekey) try: txId = signedtxn.transaction.gettxid() # send transaction txId =algodclient.sendtransactions([signedtxn]) # await confirmation transaction.waitforconfirmation(algodclient, txId,4) return {'status': True,'rewardsentbackto':clientaddress} except Exception as err: return {'status': False,'err':err}
data=vtc(150551419,"senior rural about innocent soap require dish dial kiwi remove final shoe this quarter latin belt sunny blue sock enroll jealous tank gadget absorb pass","UFDXYZ7UN7CD457QIAYBY7E3QLTME7MFNFOW3GG2U4A6QSFET22ATMSYPU","WP6QLQHU7IYKTQWQPOJ57W6DIUWATQE2W7KUKM4FWOE3QZE6272CQLYKMA",100) print(data)
data=vtnc(150551419,"senior rural about innocent soap require dish dial kiwi remove final shoe this quarter latin belt sunny blue sock enroll jealous tank gadget absorb pass","WP6QLQHU7IYKTQWQPOJ57W6DIUWATQE2W7KUKM4FWOE3QZE6272CQLYKMA") print(data)