Overview
Egabee Actions is a powerful, integrated tool provided by Egabee to automate development workflows directly within your Egabee project. It allows you to automate your build, test, alerts, and deployment pipelines by defining workflows in your Subsquid, Subquery, or Subgraph project.
Egabee is going to support deploying your Subsquid, Subquery, or Subgraph project. The project will be executed only when action conditions are met, think of it like a serverless backend.
Getting Started
To start using Egabee Actions:
Currently, the only way to trigger your web3 action is to make a post request to your action from your Subsquid, Subquery, Subgraph, or manually.
@egabee/actions
Install
Copy npm i @egabee/actions
Subsquid
Copy // src/processor.ts
import { TypeormDatabase } from "@subsquid/typeorm-store";
import axios from 'axios' // Or use fetch
import { ActionRun } from '@egabee/actions'
import { processor } from "./processor";
const myAction = {
chainId: '1', // Ethereum
triggerSource: 'Subsquid'
eventType: 'Block'
}
// Replace YOUR_ACCESS_TOKEN with your actual Egabee API token
const API_KEY = '9ec43feacc7ea9e4249d544b7092c9972f620a95297ffafcdcaa9428a14d38c3'
// Replace it with your project id
const PROJECT_ID = 'e2206c00-13b5-4dcb-8fe0-96cb28221e42'
const EGABEE_API_URL = 'https://api.egabee.com/api/0/web3-actions/${PROJECT_ID}/actions/runs/'
const requestConfig = {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
}
processor.run(new TypeormDatabase(), async (ctx) => {
for (let c of ctx.blocks) {
console.log(c);
}
const endBlock = ctx.blocks.at(-1)?.header.height;
// Trigger the action with a post request
const { data } = await axios.post(url, {...myAction, payload: endBlock}, requestConfig)
console.log(data.success)
});
Subquery
Copy // src/processor.ts
import { TypeormDatabase } from "@subsquid/typeorm-store";
import fetch from 'node-fetch' // version 2.6.2 works with sandbox vm
import { ActionRun } from '@egabee/actions'
const myAction = {
chainId: '1', // Ethereum
triggerSource: 'Subquery'
eventType: 'Block'
}
// Replace YOUR_ACCESS_TOKEN with your actual Egabee API token
const API_KEY = '9ec43feacc7ea9e4249d544b7092c9972f620a95297ffafcdcaa9428a14d38c3'
// Replace it with your project id
const PROJECT_ID = 'e2206c00-13b5-4dcb-8fe0-96cb28221e42'
const EGABEE_API_URL = 'https://api.egabee.com/api/0/web3-actions/${PROJECT_ID}/actions/runs/'
const requestConfig = {
METHOD: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
}
export async function blockHandler(block: CosmosBlock): Promise<void> {
// Trigger the action with a post request
const response = await fetch(
url,
...requestConfig,
body: JSON.stringyify({...myAction, payload: block.header})
)
const data = await response.json()
console.log(data.success)
}
Last updated 10 months ago