-
Notifications
You must be signed in to change notification settings - Fork 114
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
Shumo Chu
committed
Feb 4, 2020
1 parent
35d2094
commit 8c90fa5
Showing
3 changed files
with
123 additions
and
13 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 |
---|---|---|
@@ -1,2 +1,64 @@ | ||
Acessing Transaction Field | ||
========================== | ||
.. _transaction-fields: | ||
|
||
Transaction Fields and Global Parameters | ||
======================================== | ||
|
||
A PyTeal expression can be the value of a field of | ||
the current transaction or the value of a global parameter. | ||
Blow are the PyTeal expressions that refer to transaction fields: | ||
|
||
================================= ======================= ======================================================================= | ||
Operator Type Notes | ||
================================= ======================= ======================================================================= | ||
:code:`Txn.sender()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.fee()` :code:`TealType.uint64` in microAlgos | ||
:code:`Txn.first_valid()` :code:`TealType.uint64` round number | ||
:code:`Txn.first_valid_time()` :code:`TealType.uint64` causes program to fail, reserved for future use | ||
:code:`Txn.last_valid()` :code:`TealType.uint64` round number | ||
:code:`Txn.note()` :code:`TealType.bytes` | ||
:code:`Txn.lease()` :code:`TealType.bytes` | ||
:code:`Txn.receiver()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.amount()` :code:`TealType.uint64` in microAlgos | ||
:code:`Txn.close_remainder_to()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.vote_pk()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.selection_pk()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.vote_first()` :code:`TealType.uint64` | ||
:code:`Txn.vote_last()` :code:`TealType.uint64` | ||
:code:`Txn.vote_key_dilution()` :code:`TealType.uint64` | ||
:code:`Txn.type()` :code:`TealType.bytes` | ||
:code:`Txn.type_enum()` :code:`TealType.uint64` see table below | ||
:code:`Txn.xfer_asset()` :code:`TealType.uint64` asset ID | ||
:code:`Txn.asset_amount()` :code:`TealType.uint64` value in Asset's units | ||
:code:`Txn.asset_sender()` :code:`TealType.bytes` 32 byte address, causes clawback of all value if sender is the Clawback | ||
:code:`Txn.asset_receiver()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.asset_close_to()` :code:`TealType.bytes` 32 byte address | ||
:code:`Txn.group_index()` :code:`TealType.uint64` position of this transaction within a transaction group | ||
:code:`Txn.tx_id()` :code:`TealType.bytes` the computed ID for this transaction, 32 bytes | ||
================================= ======================= ======================================================================= | ||
|
||
:code:`Txn.type_enum()` values: | ||
|
||
============== ============ ========================= | ||
Value Type String Description | ||
============== ============ ========================= | ||
:code:`Int(0)` unkown unknown type, invalid | ||
:code:`Int(1)` pay payment | ||
:code:`Int(2)` keyreg key registration | ||
:code:`Int(3)` acfg asset config | ||
:code:`Int(4)` axfer asset transfer | ||
:code:`Int(5)` afrz asset freeze | ||
============== ============ ========================= | ||
|
||
PyTeal expressions that refer to global parameters: | ||
|
||
============================== ======================= ============================================================ | ||
Operator Type Notes | ||
============================== ======================= ============================================================ | ||
:code:`Global.min_txn_fee()` :code:`TealType.uint64` in microAlgos | ||
:code:`Global.min_balance()` :code:`TealType.uint64` in mircoAlgos | ||
:code:`Global.max_txn_life()` :code:`TealType.uint64` number of rounds | ||
:code:`Global.zero_address()` :code:`TealType.bytes` 32 byte address of all zero bytes | ||
:code:`Global.group_size()` :code:`TealType.uint64` number of txns in this atomic transaction group, At least 1 | ||
============================== ======================= ============================================================ | ||
|
||
|
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
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 |
---|---|---|
@@ -1,2 +1,48 @@ | ||
.. _atomic_transfer: | ||
|
||
Atomic Transfer | ||
=============== | ||
|
||
`Atomic Transfer <https://developer.algorand.org/docs/atomic-transfers>`_ are irreducible batch transactions | ||
that allow groups of transactions to be submitted at one time. | ||
If any of the transactions fail, then all the transactions will fail. | ||
PyTeal uses :code:`Gtxn` operator to access transactions in an atomic transfer. | ||
For example: :: | ||
|
||
Gtxn.sender(1) | ||
|
||
gets the sender of the second (Atomic Transfers are 0 indexed) transaction in the atomic transaction group. | ||
|
||
List of :code:`Gtxn` operators: | ||
|
||
=================================== ======================= ======================================================================= | ||
Operator Type Notes | ||
=================================== ======================= ======================================================================= | ||
:code:`Gtxn.sender(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.fee(n)` :code:`TealType.uint64` in microAlgos | ||
:code:`Gtxn.first_valid(n)` :code:`TealType.uint64` round number | ||
:code:`Gtxn.first_valid_time(n)` :code:`TealType.uint64` causes program to fail, reserved for future use | ||
:code:`Gtxn.last_valid(n)` :code:`TealType.uint64` round number | ||
:code:`Gtxn.note(n)` :code:`TealType.bytes` | ||
:code:`Gtxn.lease(n)` :code:`TealType.bytes` | ||
:code:`Gtxn.receiver(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.amount(n)` :code:`TealType.uint64` in microAlgos | ||
:code:`Gtxn.close_remainder_to(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.vote_pk(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.selection_pk(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.vote_first(n)` :code:`TealType.uint64` | ||
:code:`Gtxn.vote_last(n)` :code:`TealType.uint64` | ||
:code:`Gtxn.vote_key_dilution(n)` :code:`TealType.uint64` | ||
:code:`Gtxn.type(n)` :code:`TealType.bytes` | ||
:code:`Gtxn.type_enum(n)` :code:`TealType.uint64` see table below | ||
:code:`Gtxn.xfer_asset(n)` :code:`TealType.uint64` asset ID | ||
:code:`Gtxn.asset_amount(n)` :code:`TealType.uint64` value in Asset's units | ||
:code:`Gtxn.asset_sender(n)` :code:`TealType.bytes` 32 byte address, causes clawback of all value if sender is the Clawback | ||
:code:`Gtxn.asset_receiver(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.asset_close_to(n)` :code:`TealType.bytes` 32 byte address | ||
:code:`Gtxn.group_index(n)` :code:`TealType.uint64` position of this transaction within a transaction group | ||
:code:`Gtxn.tx_id(n)` :code:`TealType.bytes` the computed ID for this transaction, 32 bytes | ||
=================================== ======================= ======================================================================= | ||
|
||
where :code:`n >= 0 && n < 16`. | ||
|