Ethereum in real-time: Dagger — Simple engine to get Ethereum transactions, receipts and events in real-time

Somedays ago, someone sent random transaction to Parity Wallet and accidentally locked funds. No one knew about it until that person informed the team on Github. Currently there is no way to receive transaction (filtered) events from Ethereum and process them.

Etherscan sends you an email whenever anyone deposits to your accounts. But we need more ways to get informed whenever something happens on contracts. Simple example: getting a slack message or mobile notification when someone withdraws more than 10ETH or 1000 Tokens from your Multi-sig wallet?

To make that possible, we have created Dagger. We at Matic Network aim to make current decentralized eco-system more usable and easy for users and we believe Dagger helps developers to achieve that.

Dagger

Dagger is a simple development tool to get blocks, transactions or events triggered by Ethereum blockchain.

It uses pub/sub mechanism (MQTT protocol). Once you subscribe particular topic, you will start receiving messages that matches subscribed topic.

You can subscribe as many as topics you want.

We have already created javascript library which you use on Node and browser as well. You can use one of any available MQTT libraries to interact with Dagger.

var Dagger = require('eth-dagger'); // connect to Dagger ETH main network (network id: 1) over web socket var dagger = new Dagger('ws://mainnet.dagger.matic.network:1884'); // dagger server // Use mqtt protocol for node (socket) // var dagger = new Dagger('mqtt://mainnet.dagger.matic.network:1883'); // dagger server // get new block as soon as it gets created dagger.on('latest:block', function(result) { console.log("New block created: ", result.data); }); // get only block number (as it gets created) dagger.on('latest:block.number', function(result) { console.log("Current block number: ", result.data); });
Get latest Ethereum block using Dagger ?

Use cases

Here are some use-cases (not limited)

  • Send emails to your DApp users when their contracts get created and they are ready to use
  • Watch ERC20 token transfer from particular address
// web3 contract var web3Contract = new web3.eth.Contract(abi, address); // dagger contract var contract = dagger.contract(web3Contract); var filter = contract.events.Transfer({filter: {from: ‘0x123456...’}, room: ‘latest’}); // watch filter.watch(function(data, removed){ // data.returnValues.to : address to which it has been transferred to // data.returnValues.value : value which has been transferred }); // watch only once filter.watchOnce(function(data, removed){ // data.returnValues.to : address to which it has been transferred to // data.returnValues.value : value which has been transferred }); // stop watching filter.stopWatching();
Watch ERC20 token transfer from mentioned address ?
  • Receive slack messages when someone withdraws 1000 tokens
  • Automatically send broadcast new transaction when future block ‘X’ gets created
  • … and many more …

You can connect Dagger with any third party services using IFTTT or Zapier.

Here is an example to store every outgoing Aragon Multisig Wallet transaction into Airtable.

Here are useful links:

Dagger: https://matic.network/dagger
Dagger examples: https://github.com/jdkanani/eth-dagger-examples
Javascript library: https://github.com/maticnetwork/eth-dagger.js

Let us know how we can make Dagger better for developers to help them make better DApps.

Stay in touch with us by following us on Twitter.

More from the Polygon Blog
Polygon Reaches First Sustainability Milestone by Achieving Network Carbon Neutrality

Polygon has made a major first step toward becoming carbon negative with the retirement of $400,000 in carbon credits representing 104,794 tonnes of greenhouse gasses, or the entirety of the network’s CO2 debt since inception.  The milestone comes after Polygon in mid-April released its Green Manifesto, part of its broader vision for sustainable development. The […]

Read More
State of Governance #2: Identity & Reputation

Clink Clank For a period of time, democracy in ancient Athens was exercised in a peculiar way.* Every eligible voter, when entering the hall, would receive a single pebble to be cast in one of two urns during assembly, signifying approval or disapproval on an issue. Athenians, understanding the significance of votes being cast anonymously, […]

Read More
Why Neobanks Will Lead TradFi’s Shift to Web3

Conventional wisdom has it that traditional finance (TradFi) and decentralized finance (DeFi) go together like vampires and garlic. But there is one area of TradFi where that black-and-white picture shades into gray. This is the case for why neobanks will be key to bridging these two worlds. Neobanks, or digital banks, are basically banks without […]

Read More
Polygon ID x Polygon DAO Integration Launches to Create New ZK-based Governance Frameworks

Today, we’re launching the first iteration of Polygon ID - a private and self-sovereign identity solution powered by zero-knowledge cryptography. To start, Polygon ID enables a whole host of features previously inaccessible to DAOs. It will be integrated with Polygon DAO beginning today, and many more DAOs to come soon.  Too often, we’re forced to […]

Read More
Announcing Polygon Pod, a Podcast From the Epicenter of Web3

What’s the future of DeFi? How can blockchain projects shake the reputation for being bad for the environment? What in the world are zero knowledge proofs? How can Web3 attract and accommodate the next billion users? When Flippening? You want to know the answers and so do we. That’s why Polygon is launching Polygon Pod […]

Read More
crossmenuchevron-down-circle