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.
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
npmi@egabee/actions
Subsquid
// src/processor.tsimport { TypeormDatabase } from"@subsquid/typeorm-store";import axios from'axios'// Or use fetchimport { ActionRun } from'@egabee/actions'import { processor } from"./processor";constmyAction= { chainId:'1',// Ethereum triggerSource:'Subsquid' eventType: 'Block'}// Replace YOUR_ACCESS_TOKEN with your actual Egabee API tokenconstAPI_KEY='9ec43feacc7ea9e4249d544b7092c9972f620a95297ffafcdcaa9428a14d38c3'// Replace it with your project idconstPROJECT_ID='e2206c00-13b5-4dcb-8fe0-96cb28221e42'constEGABEE_API_URL='https://api.egabee.com/api/0/web3-actions/${PROJECT_ID}/actions/runs/'constrequestConfig= { headers: {'Authorization':`Bearer ${API_KEY}`,'Content-Type':'application/json' }}processor.run(newTypeormDatabase(),async (ctx) => {for (let c ofctx.blocks) {console.log(c); }constendBlock=ctx.blocks.at(-1)?.header.height;// Trigger the action with a post requestconst { data } =awaitaxios.post(url, {...myAction, payload: endBlock}, requestConfig)console.log(data.success)});
Subquery
// src/processor.tsimport { TypeormDatabase } from"@subsquid/typeorm-store";import fetch from'node-fetch'// version 2.6.2 works with sandbox vmimport { ActionRun } from'@egabee/actions'constmyAction= { chainId:'1',// Ethereum triggerSource:'Subquery' eventType: 'Block'}// Replace YOUR_ACCESS_TOKEN with your actual Egabee API tokenconstAPI_KEY='9ec43feacc7ea9e4249d544b7092c9972f620a95297ffafcdcaa9428a14d38c3'// Replace it with your project idconstPROJECT_ID='e2206c00-13b5-4dcb-8fe0-96cb28221e42'constEGABEE_API_URL='https://api.egabee.com/api/0/web3-actions/${PROJECT_ID}/actions/runs/'constrequestConfig= { METHOD:'POST', headers: {'Authorization':`Bearer ${API_KEY}`,'Content-Type':'application/json' }}exportasyncfunctionblockHandler(block:CosmosBlock):Promise<void> {// Trigger the action with a post requestconstresponse=awaitfetch( url,...requestConfig, body: JSON.stringyify({...myAction, payload:block.header}) )constdata=awaitresponse.json()console.log(data.success)}