Use custom contract calls
In this section we show how to use implement support for custom contract calls in ContractCondition
.
Let's start with the following example:
First, let's take a look at myFunctionAbi
:
We define a complete function ABI with
name
,type
,stateMutability
,inputs
, andoutputs
With those fields in place, our function shapes up to be defined as
myFunction(address, uint256): uint256
Note that
type
field required to befunction
andstateMutability
topure
andview
to avoid accidentally mutating the contract state
Now, looking at myContractCallCondition
we can see that:
We need to pass
myFunction
asmethod
andmyFunctionAbi
asfunctionAbi
for our contract call to be recognized correctlyWe've mapped our function parameters to
parameters
, so thataddress
is represented as':userAddress'
anduint256
is represented as':myCustomParam'
. See Condition Context and Context Variables for more details.Lastly, the
myFunctionAbi.outputs
will be used byreturnValueTest
to compare with the selected thresholdvalue
, resulting in a testmyFunctionAbi.outputs[0] > 0
Learn more
See how to implement access control revocation using custom contract calls here.
Last updated