Defender Autotask + Sentinel + Relayer

Hi Team!

I'm looking into Defender + Sentinel + Autotasks right now to trigger an autotask every time an event is emitted from my contract.

The example autotask in the docs has the signature function(params) while the autotask with injected Relayer is function(credentials).

How do I access both, i.e the payload from the Sentinel event as well as a relayer to execute a tx?

Tried it without the sentinel trigger but rather directly through the webhook, but always get an error saying

Error while attempting request: Transaction rejected by aggregator: not enough funds for gas

Relayer definitely has enough funds (this is arbitrum rinkeby testnet).

const { Relayer } = require('defender-relay-client');

exports.handler = async function(event) {
  const relayer = new Relayer(event);
  const {
    body,    // Object with JSON-parsed POST body
    headers, // Object with key-values from HTTP headers
    queryParameters, // Object with key-values from query parameters
  } = event.request;
  const addr = body.address;
  const amount = 1;
  const txRes = await relayer.sendTransaction({
    to: addr,
    value: amount,
    speed: 'fast',
    gasLimit: '21000',

  return txRes.hash;

They @toms! Arbitrum throws the error not enough funds for gas when you set a gas limit too low (yeah, it can be confusing). Try increasing the gasLimit of the tx, since regular transfers cost a lot more gas in an L2 than in an L1 (over 800K if I recall correctly).

1 Like

Thanks a lot, that was it! Hadn't heard of this before, but setting it to 1M worked just fine now :ok_hand:

1 Like