Comment on page


How our templating system works
We recently rolled out a new templating system based on Go Template. It will be soon hidden away by a new UI, but for now you have full access to the raw templating engine.
You can access the following fields, as well as using all the power of Go Templates to write conditions, loops etc.

Watch a Transaction

Address of the contract
Block number
Block timestamp
{{.Block.Hash }}
Block hash
Transaction from
Transaction gas
Transaction gas price
Transaction nonce
Transaction to
Transaction hash
Transaction value in WEI
Input data for the transaction
{{ .Contract.MethodName }}
Function called by the transaction, if any
Function parameter

Watch a Contract

Specific fields for a Watch a Contract trigger are:
{{ .Contract.ReturnedValues }}
All values returned by the function invoked
{{ .Contract.MatchedValues }}
All values matched by the function invoked
{{ index .Contract.ReturnedValues 1 }}
The second value returned by the function, if the function returns more than one value

Watch an Event

Specific fields for Watch an Event trigger are:
{{ .Contract.EventName }}
Name of the Event
{{ }}
Access the "to" field on the Event
{{ .Contract.EventParameters.value }}
Access the "value" field on the Event
{{ index (.Contract.EventParameters.arrayParam) 1 }}
Access the second value on an event field, if the field is an array

Custom Functions

We also support a bunch of handy custom functions:
{{ fromWei .Object N }}
Divides a value by 10^N. Useful to convert WEI to other currencies.
{{ humanTime .Object }}
Prints a timestamp in some human readable format
{{ hexToASCII .Object }}
Hex to ASCII
{{ hexToInt .Object }}
Hex to int
{{ etherscanTxLink .Object }}
Creates an Etherscan transaction link
{{ etherscanTokenLink .Object }}
Creates an Etherscan token link
{{ etherscanAddressLink .Object }}
Creates an Etherscan address link

A more complex example

You can leverage the full power of Go Templates, thus using if/else statements, for loops and so on. This is an example that combines some of the features discussed above:
{{ if eq "0xcd95b32c98423172e04b1c76841e5a73f4532a7f" }}
the amount in DAI is {{ fromWei .Contract.EventParameters.value 18 }}
{{ else }}
{{ range .Contract.EventParameters.arrayParam }}
looping through: {{ . }}
{{ end }}
{{ end }}
Last modified 3yr ago