Compass Docs
  • Collections
    • ๐Ÿš€Trending
    • ๐ŸŒฑMinting Now
    • ๐Ÿ“ƒCollection Watchlists
    • ๐Ÿ–ผ๏ธToken Window
    • โ†”๏ธCollection Activity
    • ๐Ÿ†Collection Profit Leaderboard
    • ๐ŸŽจCollection Tokens
    • ๐Ÿ‹Collection Top Holders
    • โ›๏ธCollection Mint History
    • ๐Ÿ”Collection Analytics
  • Wallets
    • ๐Ÿš€Getting started with Wallets
    • ๐Ÿ‘›Wallet overview
    • ๐Ÿ”Wallet Activity with Filtering
    • ๐Ÿ™‹Own Wallets
    • ๐ŸฅžFlips
    • ๐Ÿ‘ฅWallet Groups
    • ๐Ÿ”—Related Wallets
  • Pulse
    • ๐Ÿฅ‡Profit leaderboard
    • ๐Ÿ“ˆCompass Pulse
  • Alerts
    • โฐGetting Started with Alerts
  • Automations
    • ๐Ÿš€Getting Started with Automations
    • ๐Ÿ’ฐWallets
    • ๐Ÿ“˜Key Terms in Automations
    • ๐Ÿ”€Inputs/Outputs
    • ๐ŸงชTesting Automations
    • ๐Ÿš€Set Up Your First Listing Alert
    • ๐Ÿ”ซTriggers
      • Token Received
      • Token Sent
      • Token Bought
      • Token Sold
      • Token Minted
      • Webhook
      • Repeat
      • Token Listed
      • Telegram
      • Trigger Advanced Settings
    • ๐Ÿ’ณPricing
    • โšกCustom Actions
      • @compass/http
      • @compass/api
      • @compass/cache
      • @compass/utils
      • @compass/variables
      • @compass/wallet
Powered by GitBook
On this page
  • Usage
  • API Reference
  • Examples
  1. Automations
  2. Custom Actions

@compass/variables

This package provides functionalities to interact with the automation context in Compass. It allows you to retrieve and set variables within the context.

Usage

import variables from "@compass/variables";

API Reference

variables.get(key: string, scope?: string)

Retrieve a variable from the automation context.

  • key (required, string): The key of the variable to retrieve.

  • scope (optional, string): The scope of the variable to retrieve.

Returns the value of the variable. Returns null if the variable does not exist.

variables.set(key: string, value: any, scope?: string)

Set a variable in the automation context.

  • key (required, string): The key of the variable to set.

  • value (required, any): The value of the variable to set.

  • scope (optional, string): The scope of the variable to set.

Returns the value of the variable.

Examples

To retrieve a variable from the automation context:

import variables from "@compass/variables";

export default async function() {
    const key = 'variableKey';
    const scope = 'local';
    const value = variables.get(key, scope);
    return { value };
}

To set a variable in the automation context:

import variables from "@compass/variables";

export default async function() {
    const key = 'variableKey';
    const value = 'Hello, World!';
    const scope = 'local';
    const setValue = variables.set(key, value, scope);
    return { setValue };
}
Previous@compass/utilsNext@compass/wallet

Last updated 1 year ago

โšก