Automations SDK
![Coverage badge functions](https://raw.githubusercontent.com/rhinestonewtf/automations-sdk/main/badges/badge-functions.svg)
A TypeScript library for using Rhinestone Automations
The Rhinestone Automations Service allows you to create automations that will be executed on a smart account based on a trigger. Exisiting triggers include:
- Time-based trigger: Execute an automation at a specified time interval
- Event-based trigger: Execute an automation based on an event emitted onchain
This SDK makes it easy to interact with the Rhinestone Automations Service and create, sign and manage automations.
Using the Automations SDK
Installation
Install the Automations SDK:
npm install @rhinestone/automations-sdk
pnpm install @rhinestone/automations-sdk
yarn add @rhinestone/automations-sdk
bun install @rhinestone/automations-sdk
Quick Start
import {
createAutomationClient,
} from '@rhinestone/automations-sdk'
const automationsClient = createAutomationClient({
account: "0xc2b17e73603dccc195118a36f3203134fd7985f5",
apiKey: process.env.AUTOMATIONS_API_KEY!,
accountInitCode: '0x',
network: 11155111,
validator: '0x503b54Ed1E62365F0c9e4caF1479623b08acbe77',
})
const automation = await automationsClient.createAutomation({
type: 'time-based',
data: {
trigger: {
triggerData: {
cronExpression: '*/30 * * * * *',
startDate: new Date().getTime(),
},
},
actions: [
{
type: 'static',
target: '0x503b54Ed1E62365F0c9e4caF1479623b08acbe77',
value: 100,
callData: '0x',
},
],
maxNumberOfExecutions: 10,
},
})
const signature = sign(automation.hash)
await automationsClient.signAutomation({
automationId: automation.id,
signature: signature,
})
automation = await automationsClient.getAutomation(
automationId: automation.id,
)
console.log(automation.status)
Using this repo
To install dependencies, run:
pnpm install
To build the sdk, run:
pnpm build
To run tests, run:
pnpm test
Contributing
For feature or change requests, feel free to open a PR, start a discussion or get in touch with us.