Draft docs page: CashScript for Solidity developers (feedback wanted)

CashScript has had an open docs request since 2024 for a page aimed at developers coming from Solidity (issue #237 in the CashScript repo). I wrote a draft:

https://cashscript-for-solidity.surge.sh

It covers:

  • a side-by-side table (accounts vs UTXOs, msg.sender vs checkSig, storage vs NFT-commitment state, gas vs VM limits, deployment, events, tokens, reentrancy, time)
  • a counter contract in both languages, to show “the function updates state” vs “the transaction proposes a state and the contract verifies it”
  • authorization, transfers as outputs, concurrency, and a short checklist for EVM devs

All CashScript examples compile with cashc 0.14.0. It’s CC0, so the CashScript team can merge any part of it.

Corrections are very welcome, especially from people who have moved from EVM to CashScript: what tripped you up that isn’t on the page?

2 Likes

Thanks to the mods for approving this. A short update: since posting, I wrote four more draft pages for open docs issues in the same repos. All are CC0, so they can be copied into the official docs as-is.

Three of them are on the same site as the page above (https://cashscript-for-solidity.surge.sh), under these paths:

  • /multi-input/ : multi-input computation guide (CashScript #415)
  • /article/ : “Smart contracts on Ethereum, Bitcoin and Bitcoin Cash”, 2026 edition (CashScript #280)
  • /sighash/ : restricting the signer’s sighash (CashScript #310)

The fourth is a draft spec for paying a Nostr npub from a BCH wallet (Cashonize #405): Draft: BCH payment address from a Nostr npub

Corrections are very welcome, especially on the Solidity comparison table. If a BCH project needs docs or guides like these written, I take that kind of work for BCH.

2 Likes

There is parallelism in the execution of contracts that designers have to consider.

In short, unless otherwise prohibited, more than one UTXO may be spent from a contract at once, which in some cases would allow for the first thread to satisfy the requirements for many threads, which may lead to unintended consequences.

There are two main ways of solving this problem:

  1. Atomic spends (enforce one input), or
  2. Parallel spends (enforce constraints on the same indexed output).

There are many more exotic variations of atomic spends and parallel spends, but I believe those are the predominate transaction shapes at this time.

@2qx thanks, that’s a real gap. The counter example happens to use the same-index pattern (tx.outputs[this.activeInputIndex]), but the page never said why that matters, and someone coming from Solidity won’t expect the contract to run once per input.

I added a short section, “Several contract UTXOs in one transaction”, covering the two shapes you describe (atomic: one contract input; parallel: each input bound to the output at its own index), plus a checklist line. It credits you and points to the “Exploit and Solutions for Calculated Outputs” thread. It’s live on the same page now.

If the wording of either pattern is off, or there’s a standard idiom for “no other input uses this locking bytecode” that you’d rather I show, tell me and I’ll fix it.

1 Like

For the “no other input uses this locking bytecode” idiom, I’d avoid a broad one-input rule unless the contract truly needs global isolation; it weakens composability. A tighter check is to loop over the other inputs and require their previous-output locking scripts to differ from the active contract’s script. Also make clear that the same-index parallel pattern is the default fix for counters, while the bytecode check is for contracts that must be singleton-like.

@daviddavis thanks, that’s a clearer way to put it. I’ve updated the section on the page linked in my first post (“Several contract UTXOs in one transaction”): same-index parallel spends are now stated as the default fix for counters and per-UTXO state, the one-input rule is flagged as costing composability, and the singleton case points to your tighter check (every other input’s previous-output locking bytecode must differ from the active input’s). Credited you there.