Categories

Variable Addresses and Pre-conditions

You are here:
< All Topics

Variable addresses and pre-conditions can be defined in transactions. An operation will specify a variable destination address [x], for example “transfer 100 USD from address A to [x]”, and then a list of pre-conditions that the variable [x] must satisfy for the operation to become valid. The pre-conditions may include:

 

  • Ops: Other operations involving the same address [x]. These operations must be included in the same transaction’s list of operations.
  • UTXOs: UTXOs that are included as inputs to the transaction. The pre-condition may specify explicitly the addresses and amounts involved in the UTXO, or alternatively specify variable addresses and variable amounts along with policies that must evaluate to true on the variable addresses and variable amounts.
  • Policy: A policy applies to the variables referenced in the ops or UTXOs. Supported native policies include a credential requirement on address variables in the ops or UTXOs, and arithmetic expressions on transfer amount variables. Evaluating the policy may require auxiliary inputs, such as a credential proof or other privacy-preserving compliance proof. These inputs would be provided in the memo field of the transaction.

 

In pseudocode, an example operation with a variable address [x], variable amount [y], and pre-conditions is:

 

Operation A {

“Transfer from addrA to [x] 300 USD token”

pre-conditioned on

Op1: “Transfer from [x] to addrA [y] TCEHY tokens”

Policy1: A credential proof that [x] is accredited

Policy2: y >= 1

}

 

The validator processes transactions with variables and pre-conditions by scanning the list of operations and substituting variables until all the pre-conditions on each transaction are satisfied. For the above example, suppose that a new Operation B was added to the transaction operation list:

 

Operation B  {

“Transfer from addrB to [x] 1 TCEHY tokens”

pre-conditioned on

Op1: “Transfer from [x] to addrB [y] USD tokens”

Policy1: y > 275

<proof of addrB accreditation>

}

 

Then the validator would process this transaction and substitute for the variables. The resolutions executes:

 

{

“Transfer from addrA to addrB 300 USD”

“Transfer from addrB to addrA 1 TCEHY”

}

Table of Contents
Scroll to Top