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
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.
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"
}
}
}