Note: I do not believe externally initiated jobs are formally supported anymore.
In order to enable externally initiated jobs, you must enable developer mode on the Chainlink node.
This is NOT recommended to do in production.
With that out of the way,…
Add the following to your .env
file:CHAINLINK_DEV=true
FEATURE_EXTERNAL_INITIATORS=true
Connect to your Chainlink Node's tty
docker exec -it $CONTAINER_NAME /bin/bash
Once connected to your Chainlink Node's bash session, we need to authenticate via API credentials
chainlink admin login
You'll be prompted to enter your username/email and password
Once authenticated, we can create our external initiator
chainlink initiators create $INITIATOR_NAME http://$CONTAINER_IP_OR_DNS:$PORT/jobs
If successful, you will be provided secrets and tokens.
This is the only time that you will be given these, so be sure to copy them down somewhere.
With the external initiator created, we can now create a jobspec and send an inbound (offchain) request to the Chainlink Node
curl \
--insecure \
-X POST \
-H "X-Chainlink-EA-Secret: $SECRET_GENERATED_WHEN_CREATING_EXTERNAL_INITIATOR" \
-H "X-Chainlink-EA-AccessKey: $ACCESS_KEY_GENERATED_WHEN_CREATING_EXTERNAL)INITIATOR" \
-H "Content-Type: application/json" \
--data '{"data": { "result": { "name": "exampleName", "time": "01/18/2023", "date": "13:25:1 EST" } } }' https://$IP_HOSTNAME_OF_CHAINLINK_NODE:$PORT/v2/jobs/$RANDOMLY_GENERATED_JOB_ID/runs
type = "webhook"
schemaVersion = 1
name = "External Initiator Example 00"
externalJobID = "$RANDOMLY_GENERATED_JOB_ID"
forwardingAllowed = false
observationSource = """
parse_request [type="jsonparse" path="data.result" data="$(jobRun.requestBody)"]
encode_tx [type="ethabiencode"
abi="storeData(string date, string time, string name)"
data="{ \\"date\\": $(parse_request.date), \\"time\\": $(parse_request.time), \\"name\\": $(parse_request.name) }"]
submit_tx [type="ethtx"
to="$ON-CHAIN_CONTRACT_ADDRESS"
data="$(encode_tx)"
failOnRevert="true"]
parse_request -> encode_tx -> submit_tx
"""