@cowprotocol/cow-sdk
Version:
<p align="center"> <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" /> </p>
56 lines (40 loc) • 1.35 kB
Markdown
[![NPM Package][npm-image]][npm-url]
This is a sub-package of [web3.js][repo]
This subscriptions package is used within some [web3.js][repo] packages.
Please read the [documentation][docs] for more.
You can install the package either using [NPM](https://www.npmjs.com/package/web3-core-subscriptions) or using [Yarn](https://yarnpkg.com/package/web3-core-subscriptions)
```bash
npm install web3-core-subscriptions
```
```bash
yarn add web3-core-subscriptions
```
```js
const Web3Subscriptions = require('web3-core-subscriptions');
const sub = new Web3Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
subscriptionName: 'newHeads',
params: 0,
outputFormatter: formatters.outputBlockFormatter
},
'pendingTransactions': {
params: 0,
outputFormatter: formatters.outputTransactionFormatter
}
}
});
sub.attachToObject(myCoolLib);
myCoolLib.subscribe('newBlockHeaders', function(){ ... });
```
[]: http://web3js.readthedocs.io/en/1.0/
[]: https://github.com/ethereum/web3.js
[]: https://img.shields.io/npm/v/web3-core-subscriptions.svg
[]: https://npmjs.org/package/web3-core-subscriptions