# cashscript

> Easily write and interact with Bitcoin Cash contracts

Latest version **0.13.3** (published 2026-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install cashscript
pnpm add cashscript
yarn add cashscript
bun add cashscript
```

## Health

**Score 70/100 (B)** — status: active.

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.13.3 |
| Published | 2026-09-15 |
| First published | 2019-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 182.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 135 |
| Author | Rosco Kalis |
| Maintainers | rkalis |
| Keywords | bitcoin cash, cashscript, sdk, smart contracts, cashtokens |

## Links

- npm: https://www.npmjs.com/package/cashscript
- Repository: https://github.com/CashScript/cashscript
- Homepage: https://cashscript.org
- Issues: https://github.com/CashScript/cashscript/issues
- npm.io page: https://npm.io/package/cashscript

## Dependencies (5)

- [fflate](https://npm.io/package/fflate.md) ^0.8.2
- [semver](https://npm.io/package/semver.md) ^7.7.2
- [@bitauth/libauth](https://npm.io/package/@bitauth/libauth.md) ^3.1.0-next.8
- [@cashscript/utils](https://npm.io/package/@cashscript/utils.md) ^0.13.3
- [@electrum-cash/network](https://npm.io/package/@electrum-cash/network.md) ^4.1.3

## Recent versions

- 0.13.3 (latest) — 2026-09-15
- 0.14.0-next.5 (next) — 2026-09-15
- 0.14.0-next.4 — 2026-08-20
- 0.14.0-next.3 — 2026-07-30
- 0.14.0-next.2 — 2026-07-23
- 0.14.0-next.1 — 2026-07-07
- 0.14.0-next.0 — 2026-06-26
- 0.13.2 — 2026-06-23
- 0.13.1 — 2026-06-11
- 0.12.2 — 2026-06-11
- 0.13.0 — 2026-05-26
- 0.13.0-next.9 — 2026-05-21
- 0.13.0-next.8 — 2026-05-12
- 0.13.0-next.7 — 2026-04-14
- 0.13.0-next.6 — 2026-03-17
- … 85 more at https://npm.io/package/cashscript/versions

## README

# CashScript

[![Build Status](https://github.com/CashScript/cashscript/actions/workflows/github-actions.yml/badge.svg)](https://github.com/CashScript/cashscript/actions/workflows/github-actions.yml)
[![Coverage Status](https://img.shields.io/codecov/c/github/CashScript/cashscript.svg)](https://codecov.io/gh/CashScript/cashscript/)
[![NPM Version](https://img.shields.io/npm/v/cashscript.svg)](https://www.npmjs.com/package/cashscript)
[![NPM Monthly Downloads](https://img.shields.io/npm/dm/cashscript.svg)](https://www.npmjs.com/package/cashscript)
[![NPM License](https://img.shields.io/npm/l/cashscript.svg)](https://www.npmjs.com/package/cashscript)

CashScript is a high-level programming language for smart contracts on Bitcoin Cash. It offers a strong abstraction layer over Bitcoin Cash' native virtual machine, Bitcoin Script. Its syntax is based on Ethereum's smart contract language Solidity, but its functionality is very different since smart contracts on Bitcoin Cash differ greatly from smart contracts on Ethereum. For a detailed comparison of them, refer to the blog post [*Smart Contracts on Ethereum, Bitcoin and Bitcoin Cash*](https://kalis.me/smart-contracts-eth-btc-bch/).

See the [GitHub repository](https://github.com/CashScript/cashscript) and the [CashScript website](https://cashscript.org) for full documentation and usage examples.

## The CashScript Language
CashScript is a high-level language that allows you to write Bitcoin Cash smart contracts in a straightforward and familiar way. Its syntax is inspired by Ethereum's Solidity language, but its functionality is different since the underlying systems have very different fundamentals. See the [language documentation](https://cashscript.org/docs/language/) for a full reference of the language.

## The CashScript SDK
The main way to interact with CashScript contracts and integrate them into applications is using the CashScript SDK. This SDK allows you to import `.json` (or `.ts`) artifact files that were compiled using the `cashc` compiler and convert them to `Contract` objects. These objects are used to create new contract instances. These instances are used to interact with the contracts using the functions that were implemented in the `.cash` file. For more information on the CashScript SDK, refer to the [SDK documentation](https://cashscript.org/docs/sdk/).

### Installation
```bash
npm install cashscript
```

### Usage
```ts
import { Contract, ... } from 'cashscript';
```

Using the CashScript SDK, you can import contract artifact files, create new instances of these contracts, and interact with these instances:

```ts
...
  // Import the P2PKH artifact
  import P2PKH from './p2pkh-artifact.json' with { type: 'json' };

  // Instantiate a network provider for CashScript's network operations
  const provider = new ElectrumNetworkProvider('mainnet');

  // Create a new P2PKH contract with constructor arguments: { pkh: pkh }
  const contract = new Contract(P2PKH, [pkh], { provider });

  // Get contract balance & output address + balance
  console.log('contract address:', contract.address);
  console.log('contract balance:', await contract.getBalance());

  const transactionBuilder = new TransactionBuilder({ provider });
  const contractUtxos = await contract.getUtxos();

  const sendAmount = 10_000n;
  const destinationAddress = '... some address ...';

  // Calculate the change amount, accounting for a miner fee of 1000 satoshis
  const changeAmount = contractUtxos[0].satoshis - sendAmount - 1000n;

  // Construct a transaction with the transaction builder
  const txDetails = await transactionBuilder
    // Add a contract input that spends from the contract using the 'spend' function
    .addInput(contractUtxos[0], contract.unlock.spend(pk, new SignatureTemplate(keypair)))
    // Add an output that sends 0. 000 100 00 BCH back to the destination address
    .addOutput({ to: destinationAddress, amount: sendAmount })
    // Add a change output that sends the change back to the contract's address
    .addOutput({ to: contract.address, amount: changeAmount })
    .send();

  console.log(txDetails);
...
```

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