# 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

```typescript
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
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://multiplechain.gitbook.io/multiplechain-docs-v0.4/structure/services/transactionlistener.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
