https://github.com/ryohey/node-stratum-client
Stratum protocol client for Node.js
https://github.com/ryohey/node-stratum-client
bitcoin nodejs stratum typescript
Last synced: 3 months ago
JSON representation
Stratum protocol client for Node.js
- Host: GitHub
- URL: https://github.com/ryohey/node-stratum-client
- Owner: ryohey
- License: mit
- Created: 2018-02-10T09:34:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-10T11:00:48.000Z (over 8 years ago)
- Last Synced: 2026-01-31T14:44:09.282Z (6 months ago)
- Topics: bitcoin, nodejs, stratum, typescript
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-stratum-client
Stratum protocol client for Node.js
## Install
```bash
$ npm install node-stratum-client --save
```
## How to use
```js
import StratumClient from "node-stratum-client"
const client = new StratumClient()
const POOL_PORT = 4233
const POOL_HOST = "example.com"
const WORKER_NAME = "ABCDabcd12345678"
client.onNotify(res => {
console.log("notify", res)
})
client.onSetDifficulty(res => {
console.log("set difficulty", res)
})
client.onSocketError(error => {
console.error("socket error", error)
})
client.onSocketClose(() => {
console.log("socket closed")
})
client.connect(POOL_PORT, POOL_HOST)
.then(() => {
console.log("connection successful")
return client.authorize(WORKER_NAME)
})
.then(res => {
console.log("authorize successful", res)
return client.subscribe()
})
.then(res => {
console.log("subscription successful", res)
return client.getTransactions("0")
})
.then(res => {
console.log("getTransactions successful", res)
})
.catch(error => {
console.error("error", error)
})
```
## Development
### Watch and build
```bash
$ npm start
```
### Run tests
```bash
$ npm run test
```