⚙️Automation

Automate your smart contracts using a secure and hyper-reliable decentralized network that uses the same external network of node operators that secures billions in value. Building on Chainlink Automation will accelerate your innovation, save you time and money, and help you get to market faster so you don't have to deal with the setup cost, ongoing maintenance, and risks associated with a centralized automation stack.

Read more about Chainlink Automation

Before you begin

Before you begin, you need to ensure that you have a sufficient LINK balance to register the upkeep. You will also need a compatible automation contract. Read more

Create Automation

Deploy contract responsible for registering and managing new Upkeeps.

const { hash } = await sdk.chainlink.createAutomation({
    protocol: 'POLYGON',
    wallet
})

Get contract address

 const { contractAddress } = await sdk.transaction.getTransactionReceiptByHash({
    protocol: 'POLYGON',
    hash
})

Register Upkeep

Params:

Var typeVar NameExample valueDescription

String

name

"Test upkeep"

Name of upkeep that will be displayed in the UI.

bytes

encryptedEmail

0x

Can leave blank. If registering via UI we will encrypt email and store it here.

address

upkeepContract

Address of your Automation-compatible contract

uint32

gasLimit

500000

The maximum gas limit that will be used for your txns. Rather over-estimate gas since you only pay for what you use, while too low gas might mean your upkeep doesn't perform. Trade-off is higher gas means higher minimum funding requirement.

address

adminAddress

The address that will have admin rights for this upkeep. Use your wallet address, unless you want to make another wallet the admin.

uint8

triggerType

0 or 1

0 is Conditional upkeep, 1 is Log trigger upkeep

bytes

checkData

0x

checkData is a static input that you can specify now which will be sent into your checkUpkeep or checkLog, see interface.

bytes

triggerConfig

0x

The configuration for your upkeep. 0x for conditional upkeeps, or see next section for log triggers.

bytes

offchainConfig

0x

Leave as 0x, placeholder parameter for future.

uint96

amount

1000000000000000000

Ensure this is less than or equal to the allowance just given, and needs to be in WEI.

const { hash } = await  sdk.chainlink.registerUpkeep({
    protocol: 'POLYGON',
    wallet,
    address: contract,
    name: 'Cryptum Sdk',
    encryptedEmail: '0x',
    upkeepContract: '0x', // target contract
    gasLimit: 500000,
    triggerType: 0,
    checkData: '0x',
    triggerConfig: '0x',
    offchainConfig: '0x',
    amount: '10' // lINK
})

List all Upkeeps

Return the IDs of the upkeeps generated for the provided contract.

sdk.chainlink.listUpkeeps({
    protocol: 'POLYGON',
    address: contract
})

Get info Upkeep

Retrieve detailed information about the upkeep using its ID.

sdk.chainlink.getUpkeep({
    protocol: 'POLYGON',
    upkeepID: '26...7074'
})

Balance Upkeep

Get balance e Minimum Balance upkeep by ID.

sdk.chainlink.getBalanceUpkeep({
    protocol: 'POLYGON',
    address,
    upkeepID
})

Add Funds Upkeep

Add funds to the upkeep by ID.

sdk.chainlink.addFundsUpkeep({
    protocol: 'POLYGON',
    wallet,
    amount: '10',
    upkeepID
})

Pause Upkeep

sdk.chainlink.pauseUpkeep({
    protocol: 'POLYGON',
    wallet,
    upkeepID
})

Unpause Upkeep

sdk.chainlink.unpauseUpkeep({
    protocol: 'POLYGON',
    wallet,
    upkeepID
})

Cancel Upkeep

sdk.chainlink.cancelUpkeep({
    protocol: 'POLYGON',
    wallet,
    upkeepID
})

Withdraw Upkeep

To withdraw funds, the Upkeep administrator have to cancel the Upkeep first. There is delay once an Upkeep has been cancelled before funds can be withdrawn. The number of blocks delay varies by network and once the delay has passed, you can Withdraw funds.

sdk.chainlink.withdrawUpkeep({
    protocol: 'POLYGON',
    wallet,
    upkeepID
})

Edit Gas Limit Upkeep

sdk.chainlink.editGasLimitUpkeep({
    protocol: 'POLYGON',
    wallet,
    upkeepID,
    gasLimit: 400000
})

Last updated