1Sat Ordinals
Getting StartedDiscord
  • Protocol Specification
    • Introduction
    • Terms
    • Resolving Ordinals
      • Rare Sats
    • Test Vectors
  • Fungible Tokens
    • BSV-20
    • BSV-21
  • Public APIs
  • Libraries
  • Text Inscriptions
  • Reference Inscriptions
  • HTML Inscriptions
    • HTML References
  • Metadata
    • Ord Schema Type
    • Collection SubType
    • CollectionItem SubType
    • Signing
    • Location Tagging
    • Bitcoin Schema
  • Handling Large Files
  • Ordinal Lock
  • Managing Unspent Outputs
  • Partially Signed Transactions
  • Common Questions
  • Fair Launch
Powered by GitBook
On this page

Ordinal Lock

PreviousHandling Large FilesNextManaging Unspent Outputs

Last updated 12 months ago

WARNING: This is currently experimental, and not sufficiently tested. 
Use at your own risk.

You can lock an ordinal, creating an on-chain public listing for sale. If the listing value is transferred to the specified address, the ordinal is released to the destination given by the buyer. The listing can be canceled.

Below is the sCrypt contract. Provide a payment output, and a sellec pubkey and compile the contract.

import {
    assert,
    ByteString,
    hash160,
    hash256,
    method,
    prop,
    PubKey,
    PubKeyHash,
    SmartContract,
    Sig,
    SigHash,
} from 'scrypt-ts'

export class OrdinalLock extends SmartContract {
    @prop()
    seller: PubKeyHash

    @prop()
    payOutput: ByteString

    constructor(seller: PubKeyHash, payOutput: ByteString) {
        super(...arguments)

        this.seller = seller;
        this.payOutput = payOutput;
    }

    @method(SigHash.ANYONECANPAY_ALL)
    public purchase(destOutput: ByteString, trailingOutputs: ByteString) {
        assert(hash256(destOutput + this.payOutput + trailingOutputs) == this.ctx.hashOutputs)
    }

    @method()
    public cancel(sig: Sig, pubkey: PubKey) {
        assert(this.seller == hash160(pubkey), 'bad seller')
        assert(this.checkSig(sig, pubkey), 'signature check failed')
    }
}

destOutput is the destination output for the utxo which is locked.

Once the script is compiled, use it to mint and list an ordinal in a single 1 sat output:

1Sat_ORDINAL_LOCK <INSCRIPTION>
GitHub - shruggr/ordinal-lockGitHub
Logo