ryanwold.net

A civic-minded citizen seeking the singularity

Back to Entries

sCrypt

Series: Bitcoin
draft
Date: 2024-07-01
Tags: bitcoin

I've had a chance to play with sCrypt.

I tried to pick it up with a friend in 2023, and got caught on some obscure bug.

After the SF sCrypt Hackathon in 2024, I wanted to give it another shot, and I'm glad I did. With the help of Archie, I was able to get to some basic working concept of a Smart Contract on BSV.

Admittedly, it felt like a pretty steep (very steep) learning curve. Even as an experienced programmer, there were some new tools to work through (Typescript), concepts Transactions, and the implementation in the scrypt-ts library.

Basics

*This page outlines the programming types supported by sCrypt: https://by-example.scrypt.io/basic-types/

sCrypt is a smart contract programming language that compiles into Typescript.

Notes

When creating a smart contract, it is common to create the contract by passing a sha256 hash into the constructor function.

This hash can encode a message or some data, and it is stored as a property on the initial smart contract.

In the next call to a smart contract, it can be unlocked by passing in the secret message which then needs to be hashed and compared to the originally stored hash.

This is pretty much the most simple smart contract possible, which functions just like a normal UTXO and Pay to public key hash... Except we're not using the hash of a public key, but the hash of some other message.

Other references

By Ryan Wold · © 2024–2026 Ryan Wold

Licensed CC BY-NC 4.0. AI training requires a license — machine-readable terms.

Enjoyed this? — any BSV wallet, HandCash, or plain old dollars.

Leave a tip

Tips go directly to a Bitcoin SV address I control — peer to peer, no platform in between. A few thousand satoshis is a fraction of a cent; it's the gesture that counts.

From any BSV wallet

Scan the QR code with your wallet's camera, or copy the address.

177DwUfSTW8RkFBJzYYcgr1YB8ngbhTYAc

With HandCash or any paymail wallet

Paymail is an email-style address for Bitcoin wallets. Send any amount to afomi@handcash.io

First time using Bitcoin? Yours Wallet is an open-source browser extension wallet, and HandCash is an easy mobile wallet — either takes a minute to set up.

Prefer regular money? Support via OpenCollective.