How to set Job-specific minPayment in v2 jobs for job type webhook?

Viewed 139

Chainlink v1 jobs allowed to set job-specific mininmum Payment with the minPayment keyword

{
  "initiators": [
    {
      "type": "RunLog",
      "params": { "address": "0x51DE85B0cD5B3684865ECfEedfBAF12777cd0Ff8" }
    }
  ],
  "tasks": [
    {
      "type": "HTTPGet",
      "confirmations": 0,
      "params": { "get": "https://bitstamp.net/api/ticker/" }
    },
    {
      "type": "JSONParse",
      "params": { "path": [ "last" ] }
    },
    {
      "type": "Multiply",
      "params": { "times": 100 }
    },
    { "type": "EthUint256" },
    { "type": "EthTx" }
  ],
  "startAt": "2020-02-09T15:13:03Z",
  "endAt": null,
  "minPayment": "1000000000000000000"
}

It seems to be missing in v2 toml jobs. For now only directRequest type v2 jobs have this which were added with this PR

The v1 Job type that serves our purpose is.

  name: 'get-request',
  initiators: [
    {
      type: 'external',
      params: {
        name: process.env.CHAINLINK_EI_NAME,
        body: {},
      },
    },
  ],
  tasks: [
    {
      type: 'httpget',
    },
    {
      type: 'jsonparse',
    },
    {
      type: process.env.CHAINLINK_BRIDGE_NAME,
    },
  ],
  minPayment: '1',
};

How can we set minPayment for webhook type jobs in v2 TOML jobs?

1 Answers

You can do that using the minContractPaymentLinkJuels.

For example:

type                                 = "directrequest"
schemaVersion                        = 1
name                                 = "my job"
contractAddress                      = "ORACLE_ADDRESS_HERE"
minContractPaymentLinkJuels          = 1000000000000000000
observationSource = """
    ds1          [type=bridge name="bridge-data-feed" requestData="{\\"data\\": {\\"from\\":\\"eth\\", \\"to\\", \\"USD\\"}}"];

    ds1

For webhook type jobs, you'll actually want to use a custom spec (for example with an external initiator)

type            = "webhook"
schemaVersion   = 1
externalInitiators = [
  { name = "my-external-initiator-1", spec = "{\"minContractPaymentLinkJuels\": 1000000000000000000}" },
]
observationSource   = """
    ds1          [type=bridge name="bridge-data-feed" requestData="{\\"data\\": {\\"from\\":\\"eth\\", \\"to\\", \\"USD\\"}}"];

    ds1
"""

The spec defines the JSON payload that will be sent to the External Initiator on job creation if the external initiator has a URL, and you can check the amount sent to the node is correct.

Related