Variables
Variables enable dynamic values in Warps, allowing you to pass data between actions, from URLs, or from the environment.
Defining Variables
Variables are defined in the root-level vars object.
json
{
"vars": {
"CONTRACT_ADDRESS": "0x1234...",
"DEFAULT_AMOUNT": "1000000000000000000"
}
}Variable Sources
Static Values
Hardcoded strings or numbers.
json
"TOKEN_NAME": "USDC"URL Query Parameters (query:)
Extracts values from the Warp URL.
json
// URL: usewarp.to/send?recipient=0x123
"RECIPIENT": "query:recipient"Environment Variables (env:)
Resolves variables from the client's environment (e.g., API keys). Note: These are resolved at execution time by the client application.
json
"API_KEY": "env:WARP_API_KEY"Input Variables (as)
When you define an input with the as property, it becomes a variable available for subsequent use.
json
{
"name": "Amount",
"as": "userAmount",
"type": "uint256"
}Global Variables
These are pre-defined and available in all Warps without declaration:
| Variable | Description |
|---|---|
| The currently connected wallet address. |
| The API URL for the current chain. |
| The block explorer URL for the current chain. |
Using Variables (Interpolation)
Use the mustache syntax to inject values.
Valid Locations
You can use variables in:
titleanddescription- Action
label,description, andaddress - Contract
argsandinputsdefault values - HTTP
destinationURLs and headers - Prompt action text
nextURL stringsmessagescontent
Example: Dynamic Contract Call
json
{
"vars": {
"TOKEN": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
},
"actions": [
{
"type": "contract",
"label": "Approve {{TOKEN}}",
"address": "{{TOKEN}}",
"func": "approve",
"args": ["address:{{USER_WALLET}}", "uint256:{{MAX_AMOUNT}}"]
}
]
}Variable Scope
- Root Scope: Variables in
varsare available everywhere. - Input Scope: Variables defined by
asin inputs are available after that input is collected (in the same action or subsequent ones). - Output Scope: Results defined in
outputare available inmessages,next, oralerts.