Access other blockchains from Bitcoin trustlessly

Access other blockchains from Bitcoin trustlessly

This post was very first released on Medium

Formerly, we have actually demonstrated how to gain access toBSV blockchaininformation from clever agreements operating on it utilizingSPV (streamlined payment confirmation). We extend the concept to gain access to other SPV-compatible blockchains.

As an example, anybody can mint a token on Bitcoin SV as long as shesecureBTC for a particular time period. We offer first-ever execution, which can be a structure for a variety of other applications.

How ‘Lock to Mint’ works

Just recently, there has actually been a rise of interest in the”Lock to Mintsystem. This system assists in the time-locking of Bitcoin properties to mint BSV-20 fungible tokens on the Bitcoin network.

It is an instantiation of utilizing a wise agreement to manage the minting of BSV20 tokens (v2)we presented beforeThe “Lock to Mint” system works as a restriction in the token minting procedure of BSV-20. The agreement guarantees that the costs deal should consist of a secondary output in a time-lock.

a Bitcoin-only “lock to mint” deal

More information about how this procedure operates in a BSV-only context can be discovered in thisessence

Cross-Chain

Thisclever agreementcan be reached need the time-locking of funds on a various chain that supports timelocks and SPV, such as BTC. This is attained by confirming an SPV evidence within the wise agreement. Basically, the agreement, before minting, confirms the addition of atime-locked dealwith the proper specifications (locktime and payment location) in a BTC block. The performance of SPV enables this recognition to be computationally feasible. This is specifically open for BTC, since it takes pleasure in the greatest hashing problem in its evidence of work and hence renders it very pricey to produce a legitimate however phony block header not in the primary chain.

a “lock BTC to mint” deal

Execution

The following code is an application of such a clever agreement. We take advantage of thescrypt-ordlibrary for simple combination of ordinals.

The agreement exposes a single public technique called “mint.” Expect that we want to mint 10 brand-new tokens.

Before we call it, we need to build and transmit a time-locked deal on BTC with the suitable quantity and lock-time. The deal will be a basic P2WSH for a redeem script of the following format:

f6f5f6″ data-has-transparency=”false” decoding=”async” src=”https://coingeek.com/wp-content/uploads/2023/12/nLockTime.png” alt=” OP_CLTV OP_DROP OP_CHECKSIG” width=”681″ height=”82″ data-old-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20width=’681’%20height=’82’%20viewBox=’0%200%20681%2082’%3E%3C/svg%3E” data-src=”https://coingeek.com/wp-content/uploads/2023/12/nLockTime.png” data-srcset=”https://coingeek.com/wp-content/uploads/2023/12/nLockTime.png 681w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-300×36.png 300w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-100×12.png 100w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-400×48.png 400w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-460×55.png 460w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-110×13.png 110w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-180×22.png 180w”> < img data-dominant-color="f6f5f6" data-has-transparency="incorrect" decoding="async" src="https://coingeek.com/wp-content/uploads/2023/12/nLockTime.png" alt ="OP_CLTV OP_DROPOP_CHECKSIG” width=”681″ height=”82″ data-old-src=”information: image/svg + xml, % 3Csvg % 20xmlns =’ http://www.w3.org/2000/svg’%20width=’681’%20height=’82’%20viewBox=’0%200%20681%2082’%3E%3C/svg%3E” data-src=”https://coingeek.com/wp-content/uploads/2023/12/nLockTime.png” data-srcset=”https://coingeek.com/wp-content/uploads/2023/12/nLockTime.png 681w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-300×36.png 300w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-100×12.png 100w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-400×48.png 400w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-460×55.png 460w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-110×13.png 110w, https://coingeek.com/wp-content/uploads/2023/12/nLockTime-180×22.png 180w” >

After this deal has actually been mined and verified, we build anSPVevidence for it, including aMerkle-proofand its block header. Now, we have the ability to call the general public approach by passing the serialized deal in addition to the evidence and the rest of the specifications, which are the token location address, lock public secret and token quantity. To make it more reputable, we can request more than one verification.

The following is such a BTC time-lock deal on testnet.

70bd8b876bacd6ad9df1100f8e691bada729e28ee3d311e949868c75d0bf690b

It is fed into a minting deal on Bitcoin SV testnet.

db4d5b33eb2a095ee29ff1443613f5bc6db55c1eef724d1a5d93d0e6a2381fc7

The complete code of thewise agreementin addition toa testis offered on GitHub.

Here are likewise 2 Python scripts that we utilized to build deal for theimplementationandredemptionof a time-lock deal on BTC.

Extensions

There are numerous methods to extend the example. It generally enables a wise agreement on Bitcoin SV to gain access to other suitable blockchain information, such as blocks and deals, without relying on an oracle. We note some more examples listed below:

  • Trustless One-Way Peg-In: as in asidechainone can send out some BTC to a provided address and makes sure she can mint a covered token on Bitcoin SV. Note it is one method due toBTC’s absence of abilityto validate SPV evidence.
  • Randomness: one can utilize a BTC block as an entropy source, such as its block hash, for a video game on Bitcoin SV. It is orders of magnitude more costly to develop phony headers than on Bitcoin SV.

Cybersecurity: Blockchain is an innovation of trust

New to blockchain? Have a look at CoinGeek’s Blockchain for Beginners area, the supreme resource guide to find out more about blockchain innovation.

Find out more

Leave a Reply

Your email address will not be published. Required fields are marked *