Sentinel notification template documentation?

Hey guys, I'm setting up a sentinel notification for discoord, and I'm looking for more info about what template values are supported.

Here's the default:

**Defender Sentinel {{ sentinel.name }} Triggered**

**Network**

{{ sentinel.network }}

**Block Hash**

{{ blockHash }}

**Transaction Hash**

{{ transaction.transactionHash }}

**Transaction Link** 

[Block Explorer]({{ transaction.link }})

{{ matchReasonsFormatted }}

Is that everything available? There's a ton of data in the Match Reasons, ie. it renders to:

Match Reason 1

Type: Function

Signature: greet(name)

Condition: name == 'test'

Params:

name: test

Can I extract any of that data, specifically having just {{ event.name }} would make me happy.

1 Like

Hey @maurelian! You can find the docs for this feature here, we'll get them published to the docsite shortly. What you're looking for is:

Custom notification templates render dynamic content using inline templating. Any string surrounded by double curly braces will be resolved against the Event Schema. Deeply nested items (including those in arrays) can be accessed using dot notation.

And since the event schema looks like this:

{
  "transaction": {                // eth_getTransactionReceipt response body
    ...                           // see https://eips.ethereum.org/EIPS/eip-1474
  },
  "blockHash": "0xab..123",       // block hash from where this transaction was seen
  "matchReasons": [               // the reasons why sentinel triggered
    {
      "type": "event",            // event, function, or transaction
      "signature": "...",         // signature of your event/function
      "condition": "value > 5",   // condition expression (if any)
      "args": ["5"],              // parameters by index (unnamed are present)
      "params": { "value": "5" }  // parameters by name (unnamed are not present)
      "metadata": {...}           // metadata injected by Autotask Condition (if applicable)
    }
  ],
  "sentinel": {
    "id": "44a7d5...31df5",       // internal ID of your sentinel
    "name": "Sentinel Name",      // name of your sentinel
    "abi": [...],                 // abi of your address (or undefined)
    "address": "0x000..000",      // address your sentinel is watching
    "confirmBlocks": 0,           // number of blocks sentinel waits
    "network": "rinkeby"          // network of your address
    "chainId": 4                  // chain Id of the network
  }
}

You can do something like {{ matchReasons.0.signature }} to get the event name in the template. We don't support loops (yet), but if you define just a match reason in your sentinel, you should be good. Let us know if this works for you!

1 Like

The documentation is now available here:

Excellent thank you very much!

How do I get the value field of the transaction?

{{ transaction.value }} should do the trick!

Tried that:

Figured I'd use this existing thread since I'm also trying to setup Sentinel notifications for the first time, and am struggling to use the template syntax to make things human friendly. I checked the docs and it seems something like this isn't possible, but for example I'd love to do something where:

  • ERC-20 Transfer events give a notification of "{{ ENS || address }} sent {{ 125 }} {{ DAI }} to {{ ENS || address }}"
  • ERC-20 Approval events in the same sentinel give a notification of "{{ ENS || address }} approved {{ ENS || address }} to spend {{ 125 }} {{ DAI }}"

They specific features here being:

  • Conditionally map the match reason to a custom string
  • Replace token addresses to their symbols or names
  • Parse amounts based on the number of decimals
  • Reverse resolve addresses

Are any of these features currently possible, and if not are they planned? A potential workaround would be allowing users to specify a JS function that takes available parameters and returns a notification string, but I'm not sure if that's possible/planned either

Yeah... if there's a specific template engine being used, it'd be find just to point to those docs.

It looks like we're using the eth_getTransactionReceipt response body (see EIP-1474) for the transaction object, which doesn't have a value property.

Thank you for bringing this to our attention. We'll look into if and how we can pipe this information through.

Hi @maurelian,

We have now included the {{value}} template variable which allows you to access the transaction value property. We have also updated the documentation if you want to read more about it.