Ordinal Lock
WARNING: This is currently experimental, and not sufficiently tested.
Use at your own risk.Last updated
WARNING: This is currently experimental, and not sufficiently tested.
Use at your own risk.Last updated
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')
}
}1Sat_ORDINAL_LOCK <INSCRIPTION>