Alerting API reference
परिचय
Tenderly का Alert API आपको सरल और जटिल Alerts बनाने की अनुमति देता है। एक सरल अलर्ट में एक नियम होता है, उदाहरण के लिएmethod_call तब ट्रिगर होगा जब कोई transaction आपके public या external method को invoke करता है। एक जटिल अलर्ट में कई शर्तें हो सकती हैं, और जब वे सभी पूरी हो जाती हैं तो यह ट्रिगर होगा। उदाहरण के लिए, method_call और state_change के साथ एक अलर्ट तब ट्रिगर होगा जब कोई transaction दिए गए method को कॉल करता है और निर्दिष्ट storage slot को अपडेट करता है।
API का उपयोग करके Alert को परिभाषित करते समय, आपको निम्नलिखित निर्दिष्ट करना होगा:
- delivery channels जिन्हें alerting नियम ट्रिगर होने पर सूचित किया जाता है। Delivery Channels के बारे में अधिक देखें।
- expressions array जो alert को ट्रिगर करेगा जब व्यक्तिगत expressions द्वारा दर्शाई गई सभी शर्तें पूरी हो जाती हैं।
email, Discord, और Sentry delivery channels API (
POST /api/v1/account/{accountId}/delivery-channel) के माध्यम से बनाए जा सकते हैं। Slack, Telegram, और PagerDuty channels के लिए OAuth/bot connection flow आवश्यक है और वे केवल Dashboard के माध्यम से बनाए जा सकते हैं। सभी channels को API का उपयोग करके प्राप्त किया जा सकता है।Authentication
alerts बनाने से पहले, आपको authentication सेट अप करने और अपने प्रोजेक्ट की पहचान करने की आवश्यकता होगी:- JavaScript
- Shell
- Python
const TENDERLY_API_KEY = 'your_api_key';
const PROJECT_SLUG = 'your_project_slug';
const ACCOUNT_ID = 'me'; // Use 'me' or your specific account ID
// Base configuration for axios
const baseConfig = {
baseURL: 'https://api.tenderly.co/api/v1',
headers: {
'X-Access-Key': TENDERLY_API_KEY,
'Content-Type': 'application/json'
}
};
export TENDERLY_API_KEY="your_api_key"
export PROJECT_SLUG="your_project_slug"
export ACCOUNT_ID="me" # Use 'me' or your specific account ID
import requests
TENDERLY_API_KEY = 'your_api_key'
PROJECT_SLUG = 'your_project_slug'
ACCOUNT_ID = 'me' # Use 'me' or your specific account ID
# Base configuration for requests
base_url = 'https://api.tenderly.co/api/v1'
headers = {
'X-Access-Key': TENDERLY_API_KEY,
'Content-Type': 'application/json'
}
Expression प्रकार
आप Alerts के trigger नियम निर्दिष्ट करने के लिए विभिन्न expression प्रकारों का उपयोग कर सकते हैं।| Expression Type | Monitoring | Main Use Case | Required Arguments | Optional Arguments |
|---|---|---|---|---|
method_call | contracts में विशिष्ट function calls (direct या internal transactions लागू) | जब महत्वपूर्ण functions कॉल होते हैं तो ट्रैक करें | - address: Contract address; signature: function_name और input_types (क्रमबद्ध ABI input types, जैसे ["address", "uint256"]) वाला object | - transaction_type: “any” (default), “direct”, “source”, या “internal”; parameter_conditions: शर्तों का Array; not: boolean |
whitelisted_caller_addresses | विशिष्ट addresses से कॉल के लिए | Allow-list आधारित access control | - addresses: Ethereum addresses का Array | कोई नहीं |
blacklisted_caller_addresses | ब्लॉक किए गए addresses से कॉल के लिए | Block-list आधारित access control | - addresses: Ethereum addresses का Array | कोई नहीं |
contract_address | विशिष्ट contract interactions | contract के साथ सभी interactions को ट्रैक करें | - address: Contract address | - transaction_type: “direct”, “source”, या “internal”; omit करने पर direct और internal दोनों calls match होते हैं |
network | विशिष्ट networks पर events | Multi-chain monitoring | - network_id: Network/chain ID | कोई नहीं |
tag | विशिष्ट tags वाले contracts | Group-आधारित monitoring | - tag: Tag string | - transaction_type: “direct”, “source”, या “internal”; omit करने पर “internal” जैसा व्यवहार |
tx_status | Transaction सफलता/विफलता | विफल transactions को ट्रैक करें | कोई नहीं | - transaction_success: boolean |
tx_value | Transaction value | बड़े transfers को ट्रैक करें | - transaction_value: wei में राशि; operator: Comparison operator | कोई नहीं |
emitted_log | Contract events | विशिष्ट events को ट्रैक करें | - address: Contract address; event_name: Event name; event_id: Event signature | - match_any: boolean (किसी भी contract के logs से match); match_non_project_contracts: boolean; decode_events: boolean; parameter_conditions: शर्तों का Array; not: boolean |
state_change | Contract state changes | storage changes को ट्रैक करें | - address: Contract address; parameter_conditions: शर्तों का Array | - match_any: boolean (किसी भी contract पर state changes से match); match_non_project_contracts: boolean; not: boolean; comparison विकल्प (threshold, percentage) |
view_function | Read-only function results | गणना किए गए मान ट्रैक करें | - address: Contract address; input: ABI encoded function data; network_id: Network ID | - parameter_condition: Value comparison; not: boolean |
eth_balance | ETH balance changes | balance thresholds को ट्रैक करें | - address: Contract address; threshold: wei में Balance | - operator: Comparison operator (default <=); not: boolean |
erc20_transfer_matcher | ERC20 transfer consistency | transfer mechanics को validate करें | - address: Token address; log_name: Event name; balances: State variable name | कोई नहीं |
नोट्स
- ये वे सभी expression प्रकार हैं जिन्हें API स्वीकार करता है। किसी अन्य
typevalue वाला payload400(“Expressions are not in the right format”) के साथ अस्वीकार कर दिया जाता है। - एक alert के भीतर सभी expressions AND-ed होते हैं: alert केवल तभी fire करता है जब हर expression एक ही transaction से मेल खाता है। स्वतंत्र शर्तों की निगरानी के लिए, प्रत्येक के लिए अलग alert बनाएँ।
- comparison operators (
operator) के लिए, मान्य मान हैं:>,>=,<,<=,==,!=,contains,notContains - Parameter types (
parameter_type) में शामिल हैं:uint,int,bool,address,string,slice,array,tuple,fixed_bytes,bytes,hash,function - Expression प्रकार
emitted_log,erc20_transfer_matcher,eth_balance,tx_value,method_call,state_change,tx_status, औरview_functionएक वैकल्पिकnot: truefield का समर्थन करते हैं जो match को negate करता है eth_balanceकेवल तब fire करता है जब कोई transaction balance को threshold के पार ले जाता है (non-matching से matching), हर उस transaction पर नहीं जब तक शर्त बनी रहती है- सभी addresses मान्य Ethereum addresses होने चाहिए (
0xउपसर्ग वाले, 40 hex वर्ण) - Wei मान बड़ी संख्याओं को संभालने के लिए strings के रूप में पास किए जाने चाहिए
- Network IDs लक्ष्य blockchain से मेल खाना चाहिए (जैसे, Ethereum mainnet के लिए “1”)
सरल expressions के उदाहरण
सरल expression नियम स्थापित करने के उदाहरणों का अन्वेषण करें।1. Method Call Monitoring
Use Case: अपने smart contract में विशिष्ट function calls की निगरानी करें।- JavaScript
- Shell
- Python
const methodCallAlert = {
name: "Critical Function Call Alert",
description: "Monitors calls to critical functions",
enabled: true,
expressions: [{
type: "method_call",
expression: {
address: "0xe592427a0aece92de3edee1f18e0157c05861564",
signature: {
function_name: "unwrapWETH9", // name of the function to match
input_types: ["uint256", "address"] // ordered ABI input types
}
}
},
{
"type": "contract_address",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564"
}
}
],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
methodCallAlert,
baseConfig
);
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Critical Function Call Alert",
"description": "Monitors calls to critical functions",
"enabled": true,
"expressions": [
{
"type": "method_call",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564",
"signature": {
"function_name": "unwrapWETH9",
"input_types": ["uint256", "address"]
}
}
},
{
"type": "contract_address",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564"
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
method_call_alert = {
"name": "Critical Function Call Alert",
"description": "Monitors calls to critical functions",
"enabled": True,
"expressions": [{
"type": "method_call",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564",
"signature": {
"function_name": "unwrapWETH9",
"input_types": ["uint256", "address"]
}
}
},
{
"type": "contract_address",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564"
}
}],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=method_call_alert
)
2. State Change Monitoring
Use Case: contract state variables में परिवर्तनों की निगरानी करें, विशेष रूप से paused state या balance thresholds जैसे महत्वपूर्ण parameters को ट्रैक करने के लिए उपयोगी।- JavaScript
- Shell
- Python
const stateChangeAlert = {
name: "Critical State Change Alert",
description: "Monitors important state changes",
enabled: true,
expressions: [{
type: "state_change",
expression: {
address: "0x1234....",
parameter_conditions: [
{
parameter_name: "pause",
parameter_type: "bool",
compare_change: true
},
{
parameter_name: "totalSupply",
parameter_type: "uint",
compare_percentage: true,
comparison_value: "5",
operator: ">="
}
]
}
}],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
stateChangeAlert,
baseConfig
);
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Critical State Change Alert",
"description": "Monitors important state changes",
"enabled": true,
"expressions": [{
"type": "state_change",
"expression": {
"address": "0x1234....",
"parameter_conditions": [
{
"parameter_name": "pause",
"parameter_type": "bool",
"compare_change": true
},
{
"parameter_name": "totalSupply",
"parameter_type": "uint",
"compare_percentage": true,
"comparison_value": "5",
"operator": ">="
}
]
}
}],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
state_change_alert = {
"name": "Critical State Change Alert",
"description": "Monitors important state changes",
"enabled": True,
"expressions": [{
"type": "state_change",
"expression": {
"address": "0x1234....",
"parameter_conditions": [
{
"parameter_name": "pause",
"parameter_type": "bool",
"compare_change": True
},
{
"parameter_name": "totalSupply",
"parameter_type": "uint",
"compare_percentage": True,
"comparison_value": "5",
"operator": ">="
}
]
}
}],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=state_change_alert
)
3. Event Monitoring
Use Case: parameter filtering के साथ अपने contracts द्वारा emit किए गए विशिष्ट events की निगरानी करें।- JavaScript
- Shell
- Python
const eventAlert = {
name: "Large Transfer Event Alert",
description: "Monitors large transfer events",
enabled: true,
expressions: [{
type: "emitted_log",
expression: {
address: "0x1234....",
event_name: "Transfer",
event_id: "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
parameter_conditions: [
{
parameter_name: "amount",
parameter_type: "uint",
operator: ">=",
comparison_value: "1000000000000000000" // 1 ETH
}
],
decode_events: true
}
}],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
eventAlert,
baseConfig
);
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Large Transfer Event Alert",
"description": "Monitors large transfer events",
"enabled": true,
"expressions": [{
"type": "emitted_log",
"expression": {
"address": "0x1234....",
"event_name": "Transfer",
"event_id": "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
"parameter_conditions": [
{
"parameter_name": "amount",
"parameter_type": "uint",
"operator": ">=",
"comparison_value": "1000000000000000000"
}
],
"decode_events": true
}
}],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
event_alert = {
"name": "Large Transfer Event Alert",
"description": "Monitors large transfer events",
"enabled": True,
"expressions": [{
"type": "emitted_log",
"expression": {
"address": "0x1234....",
"event_name": "Transfer",
"event_id": "0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80",
"parameter_conditions": [
{
"parameter_name": "amount",
"parameter_type": "uint",
"operator": ">=",
"comparison_value": "1000000000000000000"
}
],
"decode_events": True
}
}],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=event_alert
)
4. Native ETH Balance Monitoring
Use Case: alert तब जब किसी address का native ETH balance एक threshold से नीचे गिर जाए, उदाहरण के लिए एक relayer या operations wallet जिसे funded रहना चाहिए। alert को एक network और एक address तक सीमित करें, फिर native balance की तुलना threshold (wei में) से करें।- JavaScript
- Shell
- Python
const balanceAlert = {
name: "Low ETH balance alert",
description: "Alerts when the native ETH balance falls below 0.1 ETH",
enabled: true,
expressions: [
// Scope to a specific network
{
type: "network",
expression: {
network_id: "1" // Ethereum mainnet
}
},
// Scope to the watched address
{
type: "contract_address",
expression: {
address: "0x3b8c2f1a9d7e4605c8a1b2d3e4f5061728394a5b"
}
},
// Trigger when the native balance drops below the threshold
{
type: "eth_balance",
expression: {
address: "0x3b8c2f1a9d7e4605c8a1b2d3e4f5061728394a5b",
threshold: "100000000000000000", // 0.1 ETH in wei
operator: "<"
}
}
],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
balanceAlert,
baseConfig
);
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Low ETH balance alert",
"description": "Alerts when the native ETH balance falls below 0.1 ETH",
"enabled": true,
"expressions": [
{
"type": "network",
"expression": {
"network_id": "1"
}
},
{
"type": "contract_address",
"expression": {
"address": "0x3b8c2f1a9d7e4605c8a1b2d3e4f5061728394a5b"
}
},
{
"type": "eth_balance",
"expression": {
"address": "0x3b8c2f1a9d7e4605c8a1b2d3e4f5061728394a5b",
"threshold": "100000000000000000",
"operator": "<"
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
balance_alert = {
"name": "Low ETH balance alert",
"description": "Alerts when the native ETH balance falls below 0.1 ETH",
"enabled": True,
"expressions": [
{
"type": "network",
"expression": {
"network_id": "1"
}
},
{
"type": "contract_address",
"expression": {
"address": "0x3b8c2f1a9d7e4605c8a1b2d3e4f5061728394a5b"
}
},
{
"type": "eth_balance",
"expression": {
"address": "0x3b8c2f1a9d7e4605c8a1b2d3e4f5061728394a5b",
"threshold": "100000000000000000",
"operator": "<"
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=balance_alert
)
जटिल Alert के उदाहरण
जटिल expression नियमों को दिखाने वाले उदाहरणों का अन्वेषण करें। जबexpressions array में हर expression संतुष्ट होगा तो alert ट्रिगर होगा।
1. Security Monitoring System
Use Case: कई शर्तों को मिलाकर व्यापक security monitoring:- Admin function calls की निगरानी करें
- बड़े value transfers को ट्रैक करें
- blacklisted addresses पर नज़र रखें
- महत्वपूर्ण parameters के state changes पर alert करें
- JavaScript
- Shell
- Python
const securityAlert = {
name: "Security Monitoring System",
description: "Comprehensive security monitoring for contract",
enabled: true,
expressions: [
{
"type": "contract_address",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564"
}
},
// Admin function monitoring
{
type: "method_call",
expression: {
address: "0xe592427a0aece92de3edee1f18e0157c05861564",
signature: {
function_name: "transferOwnership",
input_types: ["address"]
}
}
},
// Blacklist checking
{
type: "blacklisted_caller_addresses",
expression: {
addresses: [
"0xblacklisted1...",
"0xblacklisted2..."
]
}
},
// Large value transfers
{
type: "tx_value",
expression: {
transaction_value: "100000000000000000000", // 100 ETH
operator: ">"
}
},
// Critical state changes
{
type: "state_change",
expression: {
address: "0x1234....",
parameter_conditions: [
{
parameter_name: "pause",
parameter_type: "bool",
compare_change: true
},
{
parameter_name: "owner",
parameter_type: "address",
compare_change: true
}
]
}
}
],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
securityAlert,
baseConfig
);
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Security Monitoring System",
"description": "Comprehensive security monitoring for contract",
"enabled": true,
"expressions": [
{
"type": "contract_address",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564"
}
},
{
"type": "method_call",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564",
"signature": {
"function_name": "transferOwnership",
"input_types": ["address"]
}
}
},
{
"type": "blacklisted_caller_addresses",
"expression": {
"addresses": [
"0xblacklisted1...",
"0xblacklisted2..."
]
}
},
{
"type": "tx_value",
"expression": {
"transaction_value": "100000000000000000000",
"operator": ">"
}
},
{
"type": "state_change",
"expression": {
"address": "0x1234....",
"parameter_conditions": [
{
"parameter_name": "pause",
"parameter_type": "bool",
"compare_change": true
},
{
"parameter_name": "owner",
"parameter_type": "address",
"compare_change": true
}
]
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
security_alert = {
"name": "Security Monitoring System",
"description": "Comprehensive security monitoring for contract",
"enabled": True,
"expressions": [
{
"type": "contract_address",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564"
}
},
{
"type": "method_call",
"expression": {
"address": "0xe592427a0aece92de3edee1f18e0157c05861564",
"signature": {
"function_name": "transferOwnership",
"input_types": ["address"]
}
}
},
{
"type": "blacklisted_caller_addresses",
"expression": {
"addresses": [
"0xblacklisted1...",
"0xblacklisted2..."
]
}
},
{
"type": "tx_value",
"expression": {
"transaction_value": "100000000000000000000",
"operator": ">"
}
},
{
"type": "state_change",
"expression": {
"address": "0x1234....",
"parameter_conditions": [
{
"parameter_name": "pause",
"parameter_type": "bool",
"compare_change": True
},
{
"parameter_name": "owner",
"parameter_type": "address",
"compare_change": True
}
]
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=security_alert
)
2. DeFi Protocol Monitor
Use Case: DeFi pool की निम्न के लिए निगरानी करें:- बड़े trades/swaps
- Liquidity परिवर्तन
- विफल transactions
- JavaScript
- Shell
- Python
const defiAlerts = [
// Alert 1: large swaps via events
{
name: "Large Swaps",
description: "Swap events moving 1000+ tokens out of the pool",
enabled: true,
expressions: [{
type: "emitted_log",
expression: {
address: "0xpool_address",
event_name: "Swap",
event_id: "0x...", // Swap event signature
parameter_conditions: [
{
parameter_name: "amountOut",
parameter_type: "uint",
operator: ">=",
comparison_value: "1000000000000000000000" // 1000 tokens
}
],
decode_events: true
}
}],
delivery_channels: [{ id: "your_channel_id", enabled: true }]
},
// Alert 2: liquidity changes
{
name: "Liquidity Shift",
description: "Pool reserves moved by 10% or more",
enabled: true,
expressions: [{
type: "state_change",
expression: {
address: "0xpool_address",
parameter_conditions: [
{
parameter_name: "reserve0",
parameter_type: "uint",
compare_percentage: true,
comparison_value: "10",
operator: ">="
},
{
parameter_name: "reserve1",
parameter_type: "uint",
compare_percentage: true,
comparison_value: "10",
operator: ">="
}
]
}
}],
delivery_channels: [{ id: "your_channel_id", enabled: true }]
},
// Alert 3: failed transactions on the pool
{
name: "Failed Transactions",
description: "Failed transactions involving the pool",
enabled: true,
expressions: [
{
type: "contract_address",
expression: { address: "0xpool_address" }
},
{
type: "tx_status",
expression: { transaction_success: false }
}
],
delivery_channels: [{ id: "your_channel_id", enabled: true }]
}
];
for (const alert of defiAlerts) {
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
alert,
baseConfig
);
}
# Alert 1: large swaps via events
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Large Swaps",
"description": "Swap events moving 1000+ tokens out of the pool",
"enabled": true,
"expressions": [{
"type": "emitted_log",
"expression": {
"address": "0xpool_address",
"event_name": "Swap",
"event_id": "0x...",
"parameter_conditions": [
{
"parameter_name": "amountOut",
"parameter_type": "uint",
"operator": ">=",
"comparison_value": "1000000000000000000000"
}
],
"decode_events": true
}
}],
"delivery_channels": [{ "id": "your_channel_id", "enabled": true }]
}'
# Alert 2: liquidity changes
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Liquidity Shift",
"description": "Pool reserves moved by 10% or more",
"enabled": true,
"expressions": [{
"type": "state_change",
"expression": {
"address": "0xpool_address",
"parameter_conditions": [
{
"parameter_name": "reserve0",
"parameter_type": "uint",
"compare_percentage": true,
"comparison_value": "10",
"operator": ">="
},
{
"parameter_name": "reserve1",
"parameter_type": "uint",
"compare_percentage": true,
"comparison_value": "10",
"operator": ">="
}
]
}
}],
"delivery_channels": [{ "id": "your_channel_id", "enabled": true }]
}'
# Alert 3: failed transactions on the pool
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Failed Transactions",
"description": "Failed transactions involving the pool",
"enabled": true,
"expressions": [
{
"type": "contract_address",
"expression": { "address": "0xpool_address" }
},
{
"type": "tx_status",
"expression": { "transaction_success": false }
}
],
"delivery_channels": [{ "id": "your_channel_id", "enabled": true }]
}'
defi_alerts = [
# Alert 1: large swaps via events
{
"name": "Large Swaps",
"description": "Swap events moving 1000+ tokens out of the pool",
"enabled": True,
"expressions": [{
"type": "emitted_log",
"expression": {
"address": "0xpool_address",
"event_name": "Swap",
"event_id": "0x...",
"parameter_conditions": [
{
"parameter_name": "amountOut",
"parameter_type": "uint",
"operator": ">=",
"comparison_value": "1000000000000000000000"
}
],
"decode_events": True
}
}],
"delivery_channels": [{"id": "your_channel_id", "enabled": True}]
},
# Alert 2: liquidity changes
{
"name": "Liquidity Shift",
"description": "Pool reserves moved by 10% or more",
"enabled": True,
"expressions": [{
"type": "state_change",
"expression": {
"address": "0xpool_address",
"parameter_conditions": [
{
"parameter_name": "reserve0",
"parameter_type": "uint",
"compare_percentage": True,
"comparison_value": "10",
"operator": ">="
},
{
"parameter_name": "reserve1",
"parameter_type": "uint",
"compare_percentage": True,
"comparison_value": "10",
"operator": ">="
}
]
}
}],
"delivery_channels": [{"id": "your_channel_id", "enabled": True}]
},
# Alert 3: failed transactions on the pool
{
"name": "Failed Transactions",
"description": "Failed transactions involving the pool",
"enabled": True,
"expressions": [
{
"type": "contract_address",
"expression": {"address": "0xpool_address"}
},
{
"type": "tx_status",
"expression": {"transaction_success": False}
}
],
"delivery_channels": [{"id": "your_channel_id", "enabled": True}]
}
]
for alert in defi_alerts:
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=alert
)
3. ERC20 Token Monitor
Use Case: Token monitoring, जिसमें शामिल है:- Transfer consistency जाँचें
- बड़े transfers की निगरानी
- Total supply परिवर्तन
- JavaScript
- Shell
- Python
const tokenAlerts = [
// Alert 1: Transfer event consistency
{
name: "Transfer Consistency",
description: "Transfer events inconsistent with balance changes",
enabled: true,
expressions: [{
type: "erc20_transfer_matcher",
expression: {
address: "0xtoken_address",
log_name: "Transfer",
balances: "balances"
}
}],
delivery_channels: [{ id: "your_channel_id", enabled: true }]
},
// Alert 2: large transfers
{
name: "Large Transfers",
description: "Transfers of 1000+ tokens",
enabled: true,
expressions: [{
type: "emitted_log",
expression: {
address: "0xtoken_address",
event_name: "Transfer",
event_id: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
parameter_conditions: [
{
parameter_name: "value",
parameter_type: "uint",
operator: ">=",
comparison_value: "1000000000000000000000" // 1000 tokens
}
]
}
}],
delivery_channels: [{ id: "your_channel_id", enabled: true }]
},
// Alert 3: total supply changes
{
name: "Supply Change",
description: "totalSupply moved by 1% or more",
enabled: true,
expressions: [{
type: "state_change",
expression: {
address: "0xtoken_address",
parameter_conditions: [
{
parameter_name: "totalSupply",
parameter_type: "uint",
compare_percentage: true,
comparison_value: "1",
operator: ">="
}
]
}
}],
delivery_channels: [{ id: "your_channel_id", enabled: true }]
}
];
for (const alert of tokenAlerts) {
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
alert,
baseConfig
);
}
# Alert 1: Transfer event consistency
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Transfer Consistency",
"description": "Transfer events inconsistent with balance changes",
"enabled": true,
"expressions": [{
"type": "erc20_transfer_matcher",
"expression": {
"address": "0xtoken_address",
"log_name": "Transfer",
"balances": "balances"
}
}],
"delivery_channels": [{ "id": "your_channel_id", "enabled": true }]
}'
# Alert 2: large transfers
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Large Transfers",
"description": "Transfers of 1000+ tokens",
"enabled": true,
"expressions": [{
"type": "emitted_log",
"expression": {
"address": "0xtoken_address",
"event_name": "Transfer",
"event_id": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"parameter_conditions": [
{
"parameter_name": "value",
"parameter_type": "uint",
"operator": ">=",
"comparison_value": "1000000000000000000000"
}
]
}
}],
"delivery_channels": [{ "id": "your_channel_id", "enabled": true }]
}'
# Alert 3: total supply changes
curl -X POST "https://api.tenderly.co/api/v1/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert" \
--header "Content-Type: application/json" \
--header "X-Access-Key: ${TENDERLY_API_KEY}" \
--data-raw '{
"name": "Supply Change",
"description": "totalSupply moved by 1% or more",
"enabled": true,
"expressions": [{
"type": "state_change",
"expression": {
"address": "0xtoken_address",
"parameter_conditions": [
{
"parameter_name": "totalSupply",
"parameter_type": "uint",
"compare_percentage": true,
"comparison_value": "1",
"operator": ">="
}
]
}
}],
"delivery_channels": [{ "id": "your_channel_id", "enabled": true }]
}'
token_alerts = [
# Alert 1: Transfer event consistency
{
"name": "Transfer Consistency",
"description": "Transfer events inconsistent with balance changes",
"enabled": True,
"expressions": [{
"type": "erc20_transfer_matcher",
"expression": {
"address": "0xtoken_address",
"log_name": "Transfer",
"balances": "balances"
}
}],
"delivery_channels": [{"id": "your_channel_id", "enabled": True}]
},
# Alert 2: large transfers
{
"name": "Large Transfers",
"description": "Transfers of 1000+ tokens",
"enabled": True,
"expressions": [{
"type": "emitted_log",
"expression": {
"address": "0xtoken_address",
"event_name": "Transfer",
"event_id": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"parameter_conditions": [
{
"parameter_name": "value",
"parameter_type": "uint",
"operator": ">=",
"comparison_value": "1000000000000000000000"
}
]
}
}],
"delivery_channels": [{"id": "your_channel_id", "enabled": True}]
},
# Alert 3: total supply changes
{
"name": "Supply Change",
"description": "totalSupply moved by 1% or more",
"enabled": True,
"expressions": [{
"type": "state_change",
"expression": {
"address": "0xtoken_address",
"parameter_conditions": [
{
"parameter_name": "totalSupply",
"parameter_type": "uint",
"compare_percentage": True,
"comparison_value": "1",
"operator": ">="
}
]
}
}],
"delivery_channels": [{"id": "your_channel_id", "enabled": True}]
}
]
for alert in token_alerts:
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=alert
)