Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/libitx/txforge
Modern Bitcoin transaction builder, capable of supporting any non-standard and custom script type.
https://github.com/libitx/txforge
bitcoin bsv javascript
Last synced: 2 months ago
JSON representation
Modern Bitcoin transaction builder, capable of supporting any non-standard and custom script type.
- Host: GitHub
- URL: https://github.com/libitx/txforge
- Owner: libitx
- License: apache-2.0
- Created: 2020-07-04T16:12:44.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-27T17:07:34.000Z (over 2 years ago)
- Last Synced: 2023-03-06T22:39:54.021Z (almost 2 years ago)
- Topics: bitcoin, bsv, javascript
- Language: JavaScript
- Homepage:
- Size: 1.83 MB
- Stars: 48
- Watchers: 5
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TxForge
![Industrial strength transaction builder](https://raw.githubusercontent.com/libitx/txforge/master/media/txforge-poster.jpg)
[![npm](https://img.shields.io/npm/v/txforge?color=informational)](https://www.npmjs.com/package/txforge)
![License](https://img.shields.io/github/license/libitx/txforge?color=informational)
![Build Status](https://img.shields.io/github/workflow/status/libitx/txforge/Node.js%20CI/v2)TxForge is an industrial strength transaction builder. Re-built on top of [nimble](https://github.com/runonbitcoin/nimble), TxForge 2.0 is an ultra-lightweight, ultra-flexible, essential part of any respectable Bitcoin builders' toolkit.
- simple, human-friendly declarative API for composing transactions
- extendable and flexible - can forge transactions with any script template imaginable
- under the hood it's powered by nimble, less that 1/5 the size of [moneybutton/bsv v2](https://github.com/moneybutton/bsv) and up to 4 times as fast!
- a robust library using well-tested, modern javascript*The legacy version of TxForge, powered by [bsv v2](https://github.com/moneybutton/bsv), can be found on the [legacy branch](https://github.com/libitx/txforge/tree/legacy).*
## Sponsors
Supported by:
Your sponsorship will help us continue to release and maintain software that Bitcoin businesses and developers depend on.
#### π [Sponsor Chronos Labs' open source work](https://www.chronoslabs.net/sponsor/)
## Upgrading
If you've used previous versions of TxForge, conceptually everything is the same. However, v2.0 is a rewrite from top to bottom, powered by a new Bitcoin library, and incorporates some API changes, most notably with how Casts are defined and used.
Full more details, check out the [TxForge 2 upgrade notes](https://github.com/libitx/txforge/wiki/Installing-and-upgrading-TxForge#txforge-2-upgrade-notes).
## Quick start
Install TxForge with `npm` or `yarn`:
```shell
npm install txforge
# or
yarn add txforge
```Alternatively use in a browser via CDN:
```html
```
Grab your tools and put on your safety googles. Lets forge a transaction... it's hammer time!
```js
import { forgeTx, toUTXO, casts } from 'txforge'// We'll use these Casts in our transaction
const { P2PKH, OpReturn } = casts// You'll need UTXOs to fund a transaction. Use the `toUTXO` helper to turn
// your UTXO data into the required objects.
const utxo = toUTXO({
txid, // utxo transaction id
vout, // utxo output index
satoshis, // utxo amount
script // utxo lock script
})// Forge a transaction
const tx = forgeTx({
inputs: [
P2PKH.unlock(utxo, { privkey: myPrivateKey })
],
outputs: [
P2PKH.lock(5000, { address: '1DBz6V6CmvjZTvfjvWpvvwuM1X7GkRmWEq' }),
OpReturn.lock(0, { data: ['meta', '1DBz6V6CmvjZTvfjvWpvvwuM1X7GkRmWEq', txid] })
],
change: { address: '1Nro9WkpaKm9axmcfPVp79dAJU1Gx7VmMZ' }
})// And behold! Forged by the Gods and found by a King - a transaction is born.
console.log(tx.toHex())
```And that's it. Really. One function that returns a fully built and signed transaction, ready to send off to your favourite transaction processor.
But there's more, much more. When you're ready, grab a coffee and dive into the following to discover how TxForge can be used to lock and unlock any combination of script template you can imagine.
- [Understanding Casts](https://github.com/libitx/txforge/wiki/Understanding-Casts)
- [Creating custom Casts](https://github.com/libitx/txforge/wiki/Creating-custom-Casts)
- [Building Scripts with TxForge](https://github.com/libitx/txforge/wiki/Building-scripts-with-the-Tape-API)## License
TxForge is open source and released under theΒ [Apache-2 License](https://github.com/libitx/txforge/blob/master/LICENSE).
Copyright (c) 2020-2022 Chronos Labs Ltd.