Condition Context and Context Variables
In this section, we introduce the ConditionContext
, a container for dynamic values to be used in conditions. We call those values "context variables" and can recognize them by the :
prefix. They act as a placeholder to be specified at the encryption time and filled at the decryption time.
Let's take a look at this ContractConditon
example:
In this example, we can see two different context variables
:userAddress
- A reserved context variable:selectedBalance
- A custom context variable
We can see that there are two types of context variables
Reserved context variables, that are used by
taco
automaticallyCustom context variables, that have to be filled manually by the decryptor
In order to replace the :userAddress
context variable with an actual user address, taco
will query the user to sign EIP712
message to confirm wallet ownership at the decryption time.
The :selectedBalance
custom context variable has to be providedomains.TESTNETd to the decrypt
function by the decryptor:
With those context parameters, our conditions is transformed at decryption time into:
This is a contrived example. Time should be taken to think through the use of custom context variables since these are provided by the user and can be set to any value. In this case the selectedBalance
value can simply be set to -1
by the user which would grant them access without owning any NFT.
There is a place for custom context variables e.g. providing a merkle tree root as a parameter to a contract function, but these type of examples would be overly complex.
Learn more
Last updated