Integrate Chainlink Operator Contract with Chainlink Node

#chainlinknode #operator.sol

Requirements

  • MetaMask browser extension.

  • Address with sufficient LINK & ETH tokens in the network where you want to deploy a smart contract

Compile and deploy and Operator.sol contract through Remix IDE

  1. Create new file, let’s call it MyOperator.sol

// MyOperator.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "@chainlink/contracts/src/v0.7/Operator.sol";
  1. Go to tab “Solidity Compiler” in sidebar. Click “Compile MyOperator.sol”

  2. Go to tab "Deploy & run transactions.

  3. Click “ENVIRONMENT” -> “Injected Provider - MetaMask”. After that, the metamask extension should open. Select the network on which you want to process transactions. We will use Goerli testnet. Important: Chainlink Node and MyOperator contract must use the same network!

  4. If everything is correct, your address should appear in the “ACCOUNT” field. In “CONTRACT” field find “Operator - @chainlink/contracts/src/v0.7/Operator.sol” and use it.

  5. Expand the DEPLOY section. There you must fill in the LINK and OWNER parameters. LINK - the address of the LINK token in the selected network. Check (Chainlink Token addresses)[https://docs.chain.link/resources/link-token-contracts/] OWNER - is your address from the metamask.

  6. Click “Transact” button, pay gas and wait when transaction is over.

  7. If everything is correct, your contract should appear in the interaction menu, in the “Deployed Contracts” section

  1. In “Deployed Contracts” section find Operator contract, which you deployed in the previous step. There is a set of contract fields that you can interact with.

  2. Find “setAuthorizedSenders” method, expand it, fill senders parameter with value [“YOUR_CHAINLINK_NODE_ACCOUNT_ADDRESS”], click “Transact” button, pay gas and await when transaction over. Important! Chainlink Node Address shows on you Chainlink Node UI, this is NOT your address from MetaMask.

  3. Find “getAuthorizedSenders” method and click on it. That should return array with your Chainlink Node Address.

Funding

  • Fund MyOperator contract with LINK. You can do this for example by Metamask transfer tokens. Be careful, it is required to sponsor at least the MINIMUM_CONTRACT_PAYMENT_LINK_JUELS configuration value in LINK on your Chainlink Node. To get started, 1-2 LINKs are usually enough.

  • Fund Chainlink Node Address with ETH. You can do this for example by Metamask transfer tokens

That’s all! Now your Chainlink node is connected to the blockchain.

Troubleshooting

Transaction reverted

Often this error occurs when you forgot to sponsor an Operator contract or Chainlink Node Address. Make sure you have sufficient funds in your accounts.

Last updated