compassDAO
  • Welcome to compassDAO
  • General Information
    • What is compassDAO?
    • Vision
    • Mission
    • Value
    • Why compassDAO?
    • What we offer?
  • How to use
    • compassStats
      • For All Users
        • Connect Wallet
        • Set Up Notifiers
        • Schedule Tasks
        • Set Alerts
      • For Devs (Data Contributor)
        • API
        • Best Practices
          • Get the balance of an address
          • Curve 3pool Proportion Monitoring
          • Curve 3pool Big Withdrawn Monitoring
    • compassSafe
      • Get Started
      • Set Up Safe Module
      • Set Role
      • Set Member
      • Interact With Dapps
      • Disable Safe Module
      • Best Practices
        • DeFi - Lending (Aave)
        • DeFi - Dex (Uniswap V3)
      • For Devs
        • execTransactionFromModule
        • execTransactionsFromModule
      • Versions
      • FAQ
  • FAQ
    • Untitled
  • Links
    • Website
    • Github
    • Twitter
    • Discord
Powered by GitBook
On this page
  • Get Script: /scripts/${scriptId}
  • Run Script: /scripts/${scriptId}/run
  1. How to use
  2. compassStats
  3. For Devs (Data Contributor)

API

The scripts can be used as Tasks and Alerts, you can also use API to integrate the script result in your service.

Get Script: /scripts/${scriptId}

curl --request GET --url https://compassdao.com/i/scripts/0x2a03cd198ab14df0

Response:

{
	"result": {
		"id": "0x2a03cd198ab14df0",
		"owner": "0x81b607b86ddf539d46301dd71cff16ddfa6b18e1",
		"code": "\nexport const name = \"My Awesome Script\"\nexport const description = \"Get balance of address\"\nexport const tag = \"eth balance\"\n\nconst formatBalance = (wei: ethers.BigNumber) =>\n  Number(Number(ethers.utils.formatEther(wei)).toFixed(4))\n\nexport const run = async ({ address }: Record<string, string>) => {\n  const provider = sdk.getDefaultProvider(\"ethereum\")\n  const balance = await provider.getBalance(address)\n\n  return {\n    address,\n    balance: formatBalance(balance),\n  }\n}\n",
		"createdAt": 1659938040107,
		"updatedAt": 1659938040107,
		"userId": 4,
		"meta": {
			"id": 114,
			"scriptId": "0x2a03cd198ab14df0",
			"name": "My Awesome Script",
			"description": "Get balance of address",
			"tag": "eth balance",
			"createdAt": 1659938040107,
			"updatedAt": 1659938040107,
			"args": "address"
		}
	}
}

Run Script: /scripts/${scriptId}/run

curl --request POST \
  --url https://compassdao.com/i/scripts/0x2a03cd198ab14df0/run \
  --header 'Content-Type: application/json' \
  --data '{
	"params": "{\"address\":\"0xd8da6bf26964af9d7eed9e03e53415d37aa96045\"}"
}'

Response:

{
	"result": {
		"scriptId": "0x2a03cd198ab14df0",
		"timeUsed": 672,
		"result": {
			"status": "fulfilled",
			"value": {
				"address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
				"balance": 1883.4684
			}
		}
	}
}
PreviousFor Devs (Data Contributor)NextBest Practices

Last updated 1 year ago