Getting your Trinity Audio player ready...

This post was first published on Medium. Read Part 2 here.

Previously, we have introduced two ways to delegate the right to spend one’s bitcoin: one at Script level, the other at transaction level.

We generalize the former to delegate to any script/smart contract, instead of a public key only. It allows one to authorize arbitrary smart contract to spend one’s bitcoin.

two hands transfering a thing

The full code is shown below:

Contract DelegateToScript

Line 9 checks the delegated script is signed and thus authorized by the owner. Line 12 and 13 ensure the delegated script goes into the spending transaction’s output as the new locking script using OP_PUSH_TX, similar to the emulation of Pay to Script Hash (P2SH).

Watch: CoinGeek New York presentation, The Path to BitCoin Adoption: How to Turn the Entire Web into Bitcoin Apps

Recommended for you

ElectrumSVP v0.1.0 launches, with self-custody security upgrades
ElectrumSVP v0.1.0 brings advanced self-custody tools for BSV users, enhancing transaction handling, fee logic, and UTXO management.
April 21, 2026
STAS 3.0: The first true layer 1 DEX on Bitcoin
Learn about STAS 3.0, a revolutionary DEX protocol on BSV that eliminates counterparty risks with on-chain token swaps and enhanced...
April 16, 2026
Advertisement
Advertisement