TransactionListener

What is it?

I think TransactionListener is one of the services that everyone in MultipleChain will love the most (of course we have ideas for future services like exchange, factory).

Because with this class you can start listening to transactions on the blockchain network in the easiest way by simply sending parameters. Below are examples in the methods section.

Methods

import { services, types } from '@multiplechain/evm-chains'

const generalListener = new services.TransactionListener(types.TransactionTypeEnum.GENERAL, {
    signer: '0x1234567890abcdef', // optional
})

generalListener.on((transaction) => {
    console.log(transaction)
})
.then(() => {
    console.log('Listening for general transactions')
})
.catch(console.error)

const status = generalListener.getStatus() // listening status

generalListener.stop() // stop listening

generalListener.start() // start listening

const contractListener = new services.TransactionListener(types.TransactionTypeEnum.CONTRACT, {
    signer: '0x1234567890abcdef', // optional
    address: '0x1234567890abcdef', // optional (contract address)
})

const coinListener = new services.TransactionListener(types.TransactionTypeEnum.COIN, {
    signer: '0x1234567890abcdef', // optional
    sender: '0x1234567890abcdef', // optional
    receiver: '0x1234567890abcdef', // optional
    amount: 100, // optional
})

const tokenListener = new services.TransactionListener(types.TransactionTypeEnum.TOKEN, {
    signer: '0x1234567890abcdef', // optional
    address: '0x1234567890abcdef', // optional (contract address)
    sender: '0x1234567890abcdef', // optional
    receiver: '0x1234567890abcdef', // optional
    amount: 100, // optional
})

const nftListener = new services.TransactionListener(types.TransactionTypeEnum.NFT, {
    signer: '0x1234567890abcdef', // optional
    address: '0x1234567890abcdef', // optional (contract address)
    sender: '0x1234567890abcdef', // optional
    receiver: '0x1234567890abcdef', // optional
    nftId: 1, // optional
})

Last updated