Getting Started with MOUNTAIN Events
Basic Workflow​
- Create Subscription: Set up monitoring for specific contract events
- Implement Webhook: Build a server to receive event notifications
- Process Events: Handle incoming blockchain events in your application
Creating Your First Subscription​
API Endpoint:
Basic Example:
import { EventNotifierApi } from '@kyuzan/mountain-public-api-client';
const eventApi = new EventNotifierApi();
const subscription = await eventApi.createEventNotifierSubscription({
subscriptionName: 'Transfer Events',
networkId: 1, // Ethereum Mainnet
address: '0x1234567890123456789012345678901234567890',
formattedAbiEvent: 'event Transfer(address indexed from, address indexed to, uint256 value)',
initialBlockNumber: 1000000,
scanInterval: 10,
webhookURL: 'https://your-app.com/webhook',
webhookMaxRetries: 3,
});
console.log('Subscription created:', subscription.eventNotifierSubscription);
Enabling Webhook Notifications​
After creating a subscription, you may need to update webhook settings to enable notifications.
API Endpoint:
Example:
// Enable webhook notifications
const updatedSubscription = await eventApi.updateEventNotifierSubscriptionWebhook({
id: subscription.eventNotifierSubscription.id,
webhookEnabled: true,
webhookURL: 'https://your-app.com/webhook',
webhookMaxRetries: 5,
});
console.log('Webhook enabled:', updatedSubscription.eventNotifierSubscription);
Next Steps​
- Implement webhook receiver - Most important step
- Understand event data format - Learn about received data structure
- Manage subscriptions - Update and monitor your subscriptions