# @ceramicnetwork/anchor-listener

> Ceramic anchor events listener

Latest version **5.4.0** (published 2024-08-19) · (Apache-2.0 OR MIT) license · 0 weekly downloads

## Install

```sh
npm install @ceramicnetwork/anchor-listener
pnpm add @ceramicnetwork/anchor-listener
yarn add @ceramicnetwork/anchor-listener
bun add @ceramicnetwork/anchor-listener
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.4.0 |
| Published | 2024-08-19 |
| First published | 2023-01-11 |
| Weekly downloads | 0 |
| License | (Apache-2.0 OR MIT) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 31.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 3Box Labs |
| Maintainers | dav1do, ceramic-velvetshark, cb3box, jpham2023, npm.3box, smrz2001, oed, paul_lecam, stbrody, ukstv |
| Keywords | ceramic, anchor |

## Links

- npm: https://www.npmjs.com/package/@ceramicnetwork/anchor-listener
- npm.io page: https://npm.io/package/@ceramicnetwork/anchor-listener

## Dependencies (3)

- [rxjs](https://npm.io/package/rxjs.md) ^7.8.1
- [@ethersproject/providers](https://npm.io/package/@ethersproject/providers.md) ^5.5.1
- [@ceramicnetwork/anchor-utils](https://npm.io/package/@ceramicnetwork/anchor-utils.md) ^5.4.0

## Recent versions

- 5.4.0 (latest) — 2024-08-19
- 5.4.1-nightly.20251117002949.0 (nightly) — 2025-11-17
- 5.4.1-rc.0 (next) — 2024-12-24
- 5.4.1-nightly.20251116003123.0 — 2025-11-16
- 5.4.1-nightly.20251115002838.0 — 2025-11-15
- 5.4.1-nightly.20251114002950.0 — 2025-11-14
- 5.4.1-nightly.20251113002938.0 — 2025-11-13
- 5.4.1-nightly.20251112002933.0 — 2025-11-12
- 5.4.1-nightly.20251111002954.0 — 2025-11-11
- 5.4.1-nightly.20251110003201.0 — 2025-11-10
- 5.4.1-nightly.20251109003124.0 — 2025-11-09
- 5.4.1-nightly.20251108002716.0 — 2025-11-08
- 5.4.1-nightly.20251107002944.0 — 2025-11-07
- 5.4.1-nightly.20251106002909.0 — 2025-11-06
- 5.4.1-nightly.20251105002955.0 — 2025-11-05
- … 743 more at https://npm.io/package/@ceramicnetwork/anchor-listener/versions

## README

# Ceramic Anchor listener

![ceramicnetwork](https://circleci.com/gh/ceramicnetwork/js-ceramic.svg?style=shield)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
[![](https://img.shields.io/badge/Chat%20on-Discord-orange.svg?style=flat)](https://discord.gg/6VRZpGP)
[![Twitter](https://img.shields.io/twitter/follow/ceramicnetwork?label=Follow&style=social)](https://twitter.com/ceramicnetwork)

## Getting started

### Installation

```
$ npm install @ceramicnetwork/anchor-listener
```

### Usage

```ts
import {
  createBlockProofsListener,
  createBlocksProofsLoader,
  createAncestorBlocksProofsLoader,
} from '@ceramicnetwork/anchor-listener'
import { take, timeout } from 'rxjs'

// Listen to new block events on the provider and load anchor proofs
const subsription = createBlockProofsListener({ chainId: 'eip155:1', confirmations: 20, provider: ... }).subscribe({
  next(event) {
    // event contains the `block` and `proofs`
  }
})
// Unsubscribe to stop listening
subscription.unsubscribe()

// Load proofs for a range of blocks
createBlocksProofsLoader({ chainId: 'eip155:1', fromBlock: 100, toBlock: 120, provider: ...  }).subscribe({
  next(event) {
    // event contains the `block` and `proofs`
  }
})

// Load proofs for blocks, walking up the parents until the expected ancestor hash is found
createAncestorBlocksProofsLoader({ chainId: 'eip155:1', initialBlock: 'latest', targetAncestorHash: '...', provider: ...  }).pipe(
  // Operators can be used to add stopping conditions
  take(50), // attempt to load maximum 50 blocks
  timeout(300_000), // timeout after 5 minutes
).subscribe({
  next(event) {
    // event contains the `block` and `proofs`
    // unless interrupted, `block.parentHash` will be `targetAncestorHash` in the last event
  }
})
```

## Development

Run tests:

```shell
npm test
```

Run linter:

```shell
npm run lint
```

## Contributing

We are happy to accept small and large contributions. Make sure to check out the
[Ceramic specifications](https://github.com/ceramicnetwork/ceramic/blob/main/SPECIFICATION.md)
for details of how the protocol works.

## License

MIT or Apache-2.0

---
_Source: https://npm.io/package/@ceramicnetwork/anchor-listener · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
