ryanwold.net

A civic-minded citizen seeking the singularity

An entry

sCrypt

Series: Bitcoin
Date: 2024-07-01
Status: draft
Tags: bitcoin
This Entry is part of the Series 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