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 द्वारा दर्शाई गई सभी शर्तें पूरी हो जाती हैं।
आप delivery channels केवल Dashboard के माध्यम से बना सकते हैं, लेकिन आप उन्हें 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 कॉल होते हैं तो ट्रैक करें | - line_number: वह line जहाँ function परिभाषित है; call_position: कॉल की स्थिति (“first”, “last”, “any”) | कोई नहीं |
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” |
network | विशिष्ट networks पर events | Multi-chain monitoring | - network_id: Network/chain ID | कोई नहीं |
tag | विशिष्ट tags वाले contracts | Group-आधारित monitoring | - tag: Tag string | - transaction_type: “direct”, “source”, या “internal” |
tx_status | Transaction सफलता/विफलता | विफल transactions को ट्रैक करें | कोई नहीं | - transaction_success: boolean |
function_params | Function parameter values | विशिष्ट function inputs को ट्रैक करें | - address: Contract address; function_line_number: Function परिभाषा line; parameter_conditions: शर्तों का Array | - Parameter विशिष्ट विकल्प |
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; decode_events: boolean; parameter_conditions: शर्तों का Array |
state_change | Contract state changes | storage changes को ट्रैक करें | - address: Contract address; parameter_conditions: शर्तों का Array | - 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 |
eth_balance | ETH balance changes | balance thresholds को ट्रैक करें | - address: Contract address; threshold: wei में Balance; operator: Comparison operator | कोई नहीं |
erc20_transfer_matcher | ERC20 transfer consistency | transfer mechanics को validate करें | - address: Token address; log_name: Event name; balances: State variable name | कोई नहीं |
tx_error | transaction errors के लिए | अप्रत्याशित विफलताओं को ट्रैक करें | कोई नहीं | - addresses_to_ignore: addresses का Array |
tx_internal_error | internal tx errors के लिए | internal call विफलताओं को ट्रैक करें | कोई नहीं | - addresses_to_match: addresses का Array |
no_action | निष्क्रियता के लिए | contract निष्क्रियता को ट्रैक करें | - check_after_seconds: Time threshold | - no_log: Log शर्तें; no_transaction: Transaction शर्तें |
sandwich_transaction | sandwich attacks के लिए | MEV गतिविधि को ट्रैक करें | - address: Contract address | - transaction_type: “direct”, “source”, या “internal” |
नोट्स
- comparison operators (
operator) के लिए, मान्य मान हैं:>,>=,<,<=,==,!=,contains,notContains - Parameter types (
parameter_type) में शामिल हैं:uint,int,bool,address,string,byte - सभी 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: {
line_number: 123, // Line where function is defined
call_position: "any" // "first", "last", or "any"
}
},
{
"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": {
"line_number": 123,
"call_position": "any"
}
},
{
"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": {
"line_number": 123,
"call_position": "any"
}
},
{
"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: {
line_number: 123,
call_position: "any"
}
},
// 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": {
"line_number": 123,
"call_position": "any"
}
},
{
"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": {
"line_number": 123,
"call_position": "any"
}
},
{
"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 protocol की निगरानी करें:- बड़े trades/swaps
- महत्वपूर्ण price प्रभाव
- Liquidity परिवर्तन
- विफल transactions
- Sandwich attacks
- JavaScript
- Shell
- Python
const defiMonitor = {
name: "DeFi Protocol Monitor",
description: "Comprehensive DeFi protocol monitoring system",
enabled: true,
expressions: [
// Monitor large swaps via events
{
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
}
},
// Monitor liquidity changes
{
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: ">="
}
]
}
},
// Monitor for sandwich attacks
{
type: "sandwich_transaction",
expression: {
address: "0xpool_address",
transaction_type: "direct"
}
},
// Monitor failed transactions
{
type: "tx_error",
expression: {
addresses_to_ignore: [] // Monitor all addresses
}
}
],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
defiMonitor,
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": "DeFi Protocol Monitor",
"description": "Comprehensive DeFi protocol monitoring system",
"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
}
},
{
"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": ">="
}
]
}
},
{
"type": "sandwich_transaction",
"expression": {
"address": "0xpool_address",
"transaction_type": "direct"
}
},
{
"type": "tx_error",
"expression": {
"addresses_to_ignore": []
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
defi_monitor = {
"name": "DeFi Protocol Monitor",
"description": "Comprehensive DeFi protocol monitoring system",
"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
}
},
{
"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": ">="
}
]
}
},
{
"type": "sandwich_transaction",
"expression": {
"address": "0xpool_address",
"transaction_type": "direct"
}
},
{
"type": "tx_error",
"expression": {
"addresses_to_ignore": []
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=defi_monitor
)
3. निष्क्रियता Alerts के साथ ERC20 Token Monitor
Use Case: व्यापक token monitoring जिसमें शामिल है:- Transfer monitoring
- Balance जांच
- State consistency जांच
- निष्क्रियता monitoring
- JavaScript
- Shell
- Python
const tokenMonitor = {
name: "ERC20 Token Monitor",
description: "Comprehensive ERC20 token monitoring with inactivity alerts",
enabled: true,
expressions: [
// Monitor Transfer event consistency
{
type: "erc20_transfer_matcher",
expression: {
address: "0xtoken_address",
log_name: "Transfer",
balances: "balances"
}
},
// Monitor large transfers
{
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
}
]
}
},
// Monitor total supply changes
{
type: "state_change",
expression: {
address: "0xtoken_address",
parameter_conditions: [
{
parameter_name: "totalSupply",
parameter_type: "uint",
compare_percentage: true,
comparison_value: "1",
operator: ">="
}
]
}
},
// Monitor for inactivity
{
type: "no_action",
expression: {
no_log: {
address: "0xtoken_address",
event_name: "Transfer",
event_id: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
},
check_after_seconds: 86400 // 24 hours
}
}
],
delivery_channels: [{
id: "your_channel_id",
enabled: true
}]
};
await axios.post(
`/account/${ACCOUNT_ID}/project/${PROJECT_SLUG}/alert`,
tokenMonitor,
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": "ERC20 Token Monitor",
"description": "Comprehensive ERC20 token monitoring with inactivity alerts",
"enabled": true,
"expressions": [
{
"type": "erc20_transfer_matcher",
"expression": {
"address": "0xtoken_address",
"log_name": "Transfer",
"balances": "balances"
}
},
{
"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"
}
]
}
},
{
"type": "state_change",
"expression": {
"address": "0xtoken_address",
"parameter_conditions": [
{
"parameter_name": "totalSupply",
"parameter_type": "uint",
"compare_percentage": true,
"comparison_value": "1",
"operator": ">="
}
]
}
},
{
"type": "no_action",
"expression": {
"no_log": {
"address": "0xtoken_address",
"event_name": "Transfer",
"event_id": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
},
"check_after_seconds": 86400
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": true
}]
}'
token_monitor = {
"name": "ERC20 Token Monitor",
"description": "Comprehensive ERC20 token monitoring with inactivity alerts",
"enabled": True,
"expressions": [
{
"type": "erc20_transfer_matcher",
"expression": {
"address": "0xtoken_address",
"log_name": "Transfer",
"balances": "balances"
}
},
{
"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"
}
]
}
},
{
"type": "state_change",
"expression": {
"address": "0xtoken_address",
"parameter_conditions": [
{
"parameter_name": "totalSupply",
"parameter_type": "uint",
"compare_percentage": True,
"comparison_value": "1",
"operator": ">="
}
]
}
},
{
"type": "no_action",
"expression": {
"no_log": {
"address": "0xtoken_address",
"event_name": "Transfer",
"event_id": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
},
"check_after_seconds": 86400
}
}
],
"delivery_channels": [{
"id": "your_channel_id",
"enabled": True
}]
}
response = requests.post(
f"{base_url}/account/{ACCOUNT_ID}/project/{PROJECT_SLUG}/alert",
headers=headers,
json=token_monitor
)