Crypto Events Handle crypto price updates in your scripts
Crypto events fire when cryptocurrency price updates are received for tracked tokens. These events provide token information and price data for both EVM and Solana chains.
The crypto_price_update event fires periodically when a tracked token's price is polled. Use this for price monitoring, logging, and building custom alert logic.
Event Type:
type : 'crypto_price_update'
source : 'crypto-price-polling'
Fields:
content.text (string)Human-readable price update message.
crypto.tokenAddress (string)Token contract address.
crypto.chain ('evm' | 'svm')Blockchain network: 'evm' for Ethereum/EVM chains, 'svm' for Solana.
crypto.chainName (string | undefined)Human-readable chain name, if available.
crypto.priceUsd (number)Current token price in USD.
crypto.previousPrice (number | undefined)Previous polled price, if available. Use to calculate price change.
Example - Price Logger:
export async function handler ( event , context ) {
const change = event.crypto.previousPrice
? ((event.crypto.priceUsd - event.crypto.previousPrice) / event.crypto.previousPrice * 100 ). toFixed ( 2 )
: 'N/A' ;
await mirra.google.sheets. appendRow ({
spreadsheetId: 'your-sheet-id' ,
sheetName: 'Price History' ,
values: [
new Date (). toISOString (),
event.crypto.tokenAddress,
event.crypto.chain,
event.crypto.priceUsd,
event.crypto.previousPrice || 'N/A' ,
`${ change }%`
]
});
return { success: true };
}
Example - Custom Price Alert:
export async function handler ( event , context ) {
// Build your own alert logic beyond simple thresholds
if ( ! event.crypto.previousPrice) {
return { success: true , skipped: true };
}
const changePercent = Math. abs (
(event.crypto.priceUsd - event.crypto.previousPrice) / event.crypto.previousPrice * 100
);
// Alert on 5%+ swings
if (changePercent >= 5 ) {
const direction = event.crypto.priceUsd > event.crypto.previousPrice ? '📈' : '📉' ;
await mirra.telegram. sendMessage ({
chatId: 'your-chat-id' ,
text: `${ direction } Price Swing! \n\n Token: ${ event . crypto . tokenAddress } \n Chain: ${ event . crypto . chain } \n Price: $${ event . crypto . priceUsd } \n Change: ${ changePercent . toFixed ( 2 ) }%`
});
}
return { success: true };
}
Subscription Examples:
// All price updates
{
"eventType" : "crypto_price_update"
}
// Only Solana tokens
{
"eventType" : "crypto_price_update" ,
"conditions" : [
{
"field" : "crypto.chain" ,
"operator" : "equals" ,
"value" : "svm"
}
]
}
// High-value tokens only
{
"eventType" : "crypto_price_update" ,
"conditions" : [
{
"field" : "crypto.priceUsd" ,
"operator" : "greater_than" ,
"value" : 100
}
]
}