Пример #1
0
stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
print(f"{os.path.basename(sys.argv[0])} start {stamp}")

goal = Goal(sys.argv[1], autosend=True)

joe = goal.new_account()
flo = goal.new_account()

txinfo, err = goal.pay(goal.account, joe, amt=500_000)
assert not err, err

# Turn off rewards for precise balance checking
txinfo, err = goal.keyreg(joe, nonpart=True)
assert not err, err
joeb = goal.balance(joe)

txinfo, err = goal.pay(goal.account, flo, amt=500_000)
assert not err, err

teal = """
#pragma version 6
 txn ApplicationID
 bz end
 // Use the rekeyed account to make a payment, and give it back
 itxn_begin
  int pay
  itxn_field TypeEnum

  txn Accounts 1
  itxn_field Sender
Пример #2
0
from datetime import datetime

stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
print(f"{os.path.basename(sys.argv[0])} start {stamp}")

goal = Goal(sys.argv[1], autosend=True)

joe = goal.new_account()

txinfo, err = goal.pay(goal.account, joe, amt=500_000)
assert not err, err

# Turn off rewards for precise balance checking
txinfo, err = goal.keyreg(joe, nonpart=True)
assert not err, err
joeb = goal.balance(joe)

# When invoked, this app funds the app that was created in the txn
# before it and invokes its start(asset) method.  Of course, this app must
# be prefunded to do so. And in real life, would want to check its
# sender as access control
fund_previous = """
#pragma version 6
 txn ApplicationID
 bz end

 itxn_begin
  int pay
  itxn_field TypeEnum

  txn GroupIndex
Пример #3
0
joe = goal.new_account()
flo = goal.new_account()

# Pays

pay = goal.pay(goal.account, receiver=joe, amt=10000)  # under min balance
txid, err = goal.send(pay, confirm=False)              # errors early
assert err

pay = goal.pay(goal.account, receiver=joe, amt=500_000)
txinfo, err = goal.send(pay)
assert not err, err
tx = txinfo['txn']['txn']
assert tx['amt'] == 500_000
assert tx['fee'] == 1000
assert goal.balance(joe) == 500_000

# Asset creation
acfg = goal.acfg(joe,
                 total=10_000, unit_name='oz', asset_name='Gold',
                 freeze=flo)
txinfo, err = goal.send(acfg)
assert not err, err
gold = txinfo['asset-index']
assert goal.balance(joe, gold) == 10_000

# Asset transfer
axfer = goal.axfer(joe, goal.account, 50, gold)
txinfo, err = goal.send(axfer)
assert err
assert goal.balance(joe, gold) == 10_000
Пример #4
0
from datetime import datetime

stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
print(f"{os.path.basename(sys.argv[0])} start {stamp}")

goal = Goal(sys.argv[1], autosend=True)

joe = goal.new_account()

txinfo, err = goal.pay(goal.account, joe, amt=500_000)
assert not err, err

# Turn off rewards for precise balance checking
txinfo, err = goal.keyreg(joe, nonpart=True)
assert not err, err
joeb = goal.balance(joe)

teal = """
#pragma version 6
 txn ApplicationID
 bz end
 // Pay the sender and Accounts[1]. Force the second fee to default high
 itxn_begin
  int pay
  itxn_field TypeEnum

  txn Sender
  itxn_field Receiver

  int 5
  itxn_field Amount