A lightweight, type-safe, and modern TypeScript client for interacting with a Bitcoin Core node using JSON-RPC.
- Supports Bitcoin Core v24+ JSON-RPC methods
- Written in modern TypeScript
- Fully typed with helpful return types
- Easy to extend
- Includes basic unit tests
npm install bitcoin-ts-client
# or
yarn add bitcoin-ts-clientimport { BitcoinClient } from 'bitcoin-ts-client';
const client = new BitcoinClient(
'http://localhost:8332', // RPC URL
'rpcuser', // RPC Username
'rpcpassword' // RPC Password
);
// Example: Get blockchain info
async function main() {
const info = await client.getBlockchainInfo();
console.log(info);
}
main();You can call common Bitcoin Core RPC methods like:
getBlockchainInfo()getNetworkInfo()getBlockCount()getBlockHash(height)getBlock(hash)getRawTransaction(txid, verbose)getNewAddress(label?, addressType?)
Want to request support for more methods? Open an issue or contribute!
This package uses Jest for testing.
npm run testTests are located under the tests/ directory.
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm run testThis project is open-source and available under the MIT License.
We welcome contributions! To contribute:
- Fork the repo
- Create a new branch:
git checkout -b feature-name - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature-name - Open a pull request
Please make sure to run tests and follow the coding style before submitting.
If you find this project useful, give it a ⭐ on GitHub. For support, open an issue.