v2

latestOpenAPI 3.1.0Apache 2.02026-07-31441011.7 MB
Actions

Create Web3 Action

Create a new Web3 Action. You can also set the Web3 Action to be deployed once it's been created.

post/v1/account/{accountSlug}/project/{projectSlug}/actions/publishFile

Path parameters

accountSlugstring required

Account slug of the user

projectSlugstring required

Project slug of the account

Request body

deployboolean required

Should Web3 Action be immediately deployed.

Example request

{
  "action": {
    "name": "block-action",
    "description": "Triggers on every 10th block on ETH Mainnet and Polygon.",
    "source": "// Do not change function name.\nconst actionFn = async (context, blockEvent) => {\n    console.log(blockEvent)\n\n    // To access project's secret\n    // let secret = await context.secrets.get('MY-SECRET')\n\n    // To access project's storage\n    // let value = await context.storage.getStr('MY-KEY')\n    // await context.storage.putStr('MY-KEY', 'MY-VALUE')\n\n    // Your logic goes here :)\n}\n// Do not change this.\nmodule.exports = { actionFn }",
    "triggerType": "BLOCK",
    "runtime": "V2",
    "function": "actionFn",
    "invocationType": "ASYNC",
    "trigger": {
      "type": "block",
      "block": {
        "network": [
          "1",
          "137"
        ],
        "blocks": 10
      }
    }
  },
  "deploy": true
}

Response

A successful response.

BlockCreateWeb3ActionPostResponse required

An object with details about created Web3 Action of Block type.

OR
PeriodicCreateWeb3ActionPostResponse required

An object with details about created Web3 Action of Periodic type.

OR
WebhookCreateWeb3ActionPostResponse required

An object with details about created Web3 Action of Webhook type.

Example response

{
  "actions": {
    "block-action": {
      "id": "349cbb00-64ad-47ec-bbcb-40bffa28559f",
      "index": 1,
      "actionId": "53712e55-eb77-4ce3-9140-685fd230396a",
      "parentActionId": "",
      "runtime": "V2",
      "function": "implementation:actionFn",
      "triggerType": "BLOCK",
      "trigger": {
        "type": "block",
        "block": {
          "network": [
            "1",
            "137"
          ],
          "blocks": 10
        }
      },
      "commitish": null,
      "source": "// Do not change function name.\nconst actionFn = async (context, blockEvent) => {\n    console.log(blockEvent)\n\n    // To access project's secret\n    // let secret = await context.secrets.get('MY-SECRET')\n\n    // To access project's storage\n    // let value = await context.storage.getStr('MY-KEY')\n    // await context.storage.putStr('MY-KEY', 'MY-VALUE')\n\n    // Your logic goes here :)\n}\n// Do not change this.\nmodule.exports = { actionFn }",
      "createdAt": "2023-12-14T18:47:19.26565Z",
      "deployRequested": true,
      "deployError": null,
      "invocationType": "ASYNC"
    }
  }
}