{"id":"HkuINgDg2X4","title":"How to Build a BTC dApp Using Chain Signatures on NEAR","description":"Learn how to build a Bitcoin dApp using NEAR’s chain signatures! In this workshop, Greg and Edson walk through two approaches: a client-side method and a smart contract-based approach. They demonstrate how NEAR's MPC (Multi-Party Computation) network enables seamless Bitcoin transactions without exposing private keys.\n\nThis session also introduces OmniTransaction.rs, a powerful library for handling Bitcoin, NEAR, and Ethereum transactions inside smart contracts. Whether you're a developer looking to integrate Bitcoin with smart contracts or just exploring NEAR's cross-chain capabilities, this is your go-to guide.\n\nTakeaways:\n• Chain Signatures enable secure Bitcoin transactions without exposing private keys.\n• Two architectures for building Bitcoin dApps: Client-side signing vs. Smart contract execution.\n• OmniTransaction.rs allows seamless cross-chain integration with Bitcoin, NEAR, and Ethereum.\n• NEAR’s MPC Network ensures decentralized signing for multi-chain applications.\n• Developers can leverage smart contracts for complex Bitcoin operations beyond standard transactions.\n\nTimestamps:\n0:00 – Intro: Building Bitcoin dApps with NEAR\n0:11 – Overview: Using Chain Signatures for Bitcoin Transactions\n1:10 – Demo: Signing and Broadcasting Bitcoin Transactions\n1:53 – Code Breakdown: Transaction Lifecycle\n2:42 – Using Bitcoin JS Lib for PSBT (Partially Signed Bitcoin Transactions)\n3:29 – Calling NEAR for Transaction Signing\n4:30 – Broadcasting Transactions via Blockstream\n5:00 – Smart Contract Approach: Using NEAR to Manage Bitcoin Transactions\n6:09 – OmniTransaction.rs: A Library for Cross-Chain Transactions\n7:00 – Closing Thoughts & Where to Learn More\n\nNEAR is the Blockchain for AI\nWebsite: https://near.org/\nNEAR AI: https://near.ai/\nIntents: https://near.org/intents\nChain Abstraction: https://www.proximity.dev/\nSharding: https://nearone.org/\n\nFor the devs\nGitHub: https://github.com/near \nDev Docs: https://docs.near.org/\nDevhub: https://devhub.near.page/ @NEARDevHub\n\nConnect with socials\nTwitter:   / nearprotocol  \nBlog: https://near.org/blog/\nMedium:   / nearprotocol  \n#NEAR #nearprotocol #NEARAI","channel_name":"NEAR Protocol","published_at":"2025-02-25T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/HkuINgDg2X4/hqdefault.jpg","transcript_text":"um hey everyone uh my name is Greg this is Edson we're going to talk about how to build a uh a Bitcoin dap using chain signatures um this is the uh basic architecture um all of this happens on the uh the client side um and essentially we um we use a Bitcoin JS lib to create a Bitcoin psbt which is a uh partially signed Bitcoin transaction uh we use that to get the uh transaction hash and uh we uh pass that transaction hash to the near MPC uh and get the um signature for that Bitcoin transaction back um and then the uh the DAP uh calls sign input async finalizes the uh Bitcoin transaction and then it Broad casts that signed transaction to the uh Bitcoin Network um this is a uh a demo of the app working see it's signing um with a near wallet um it's getting the signature back uh and then it um broadcasts the uh signed Bitcoin transaction to uh the network you can see here this is the uh successful uh Bitcoin transaction right here and um I'm just going to go through the uh the code the life cycle of the uh transaction um so this is a a normal react form uh um this calls um the get and broadcast signature um so right here this is where it constructs the uh Bitcoin psbt and um it uh it first gets all of the uh Bitcoin wallets um utxos and then it uh assigns all of the inputs and outputs of the uh Bitcoin transaction and then once we have a uh a partially signed Bitcoin transaction um we call the uh the get signature and so the way that we're doing this with uh Bitcoin JS lib um we need to pass in this key pair and this sign function that calls the near sign function and so this is the uh sign function on near uh it just constructs the uh uh transaction and then it uh calls the uh wallet.com method and so this is what pops up the um uh the near uh web wallet and so that Returns the signature and um once we uh have the signature we call this broadcast function with the uh signature passed in as a parameter and uh then we construct the uh pspt again uh and we pass in a sign function that um already has access to the signature and returns it and um after that we can call psbt finalize all inputs and we broadcast the transaction to uh blockstream which which um propagates the transaction to the Bitcoin Network and uh that's it so that's how you can um build a Bitcoin uh app using um chain signatures uh with every all of the code running in the client and um Edson is going to explain how to do the same thing but with a smart contract hey hi everyone like like GRE mentioned um we can do the same um yeah looking at the architecture of this the app the client is doing basically Gathering the utxo but connecting with the MPC Network to get the signature and then constructing everything in the client side however here we have a different architecture for a d app that is just Gathering the utx SCE but then is communicating with a near contract that internally is calling the MPC contract that is uh connected with a with a couple of uh with the MPC Network so you basically can from the client side simply gather the utx SCE execute a near transaction that is calling a near contract and this near contract will um build the transaction payload connect with the MPC contract get the signature and return everything to the client side that is ready to be broadcast broadcasted to the Bitcoin Network and um yeah that's um we we believe this pattern is very powerful because it could enable more complex logic that is it can generate um basically that is going to be executed Within a new contract now for this um basically you want to start building this type of um contracts we have prepared for you what we call the Omni transaction RS which is basically a library that allows you to create transaction payloads but not only for Bitcoin but also for near and for ethereum inside a new contract you can visit the the repository in uh near SL Omni transaction RS and here we have a a bunch of um yeah a couple of examples but here also we have more elaborated examples for instance for uh Bitcoin encoding Bitcoin signing for legacy and set with transactions and we even include examples of how to propagate that um to a Bitcoin Network and um yeah that's pretty much all","transcript_synced_at":"2026-11-03T05:06:32.175Z","segments":[{"start_seconds":0,"text":"um hey everyone uh my name is Greg this is Edson we're going to talk about how to build a uh a Bitcoin dap using chain","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=0s"},{"start_seconds":11,"text":"signatures um this is the uh basic architecture um all of this happens on","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=11s"},{"start_seconds":19,"text":"the uh the client side um and essentially we um we use a","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=19s"},{"start_seconds":25,"text":"Bitcoin JS lib to create a Bitcoin psbt which is a uh partially signed Bitcoin","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=25s"},{"start_seconds":33,"text":"transaction uh we use that to get the uh transaction hash and uh we uh pass that transaction hash to the near","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=33s"},{"start_seconds":42,"text":"MPC uh and get the um signature for that Bitcoin transaction","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=42s"},{"start_seconds":48,"text":"back um and then the uh the DAP uh calls sign input async finalizes the uh","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=48s"},{"start_seconds":57,"text":"Bitcoin transaction and then it Broad casts that signed transaction to the uh Bitcoin","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=57s"},{"start_seconds":65,"text":"Network um this is a uh a demo of the app","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=65s"},{"start_seconds":75,"text":"working see it's signing um with a near wallet","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=75s"},{"start_seconds":84,"text":"um it's getting the signature back uh and then it um broadcasts the uh","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=84s"},{"start_seconds":93,"text":"signed Bitcoin transaction to uh the network you can see here this is the uh successful uh Bitcoin","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=93s"},{"start_seconds":102,"text":"transaction right here and um I'm just going to go through the uh the code the life cycle of the uh","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=102s"},{"start_seconds":111,"text":"transaction um so this is a a normal react","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=111s"},{"start_seconds":118,"text":"form uh um this calls","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=118s"},{"start_seconds":125,"text":"um the get and broadcast signature","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=125s"},{"start_seconds":133,"text":"um so right here this is where it constructs the uh Bitcoin psbt and","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=133s"},{"start_seconds":141,"text":"um it uh it first gets all of the uh Bitcoin wallets um utxos and then it uh","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=141s"},{"start_seconds":150,"text":"assigns all of the inputs and outputs of the uh Bitcoin transaction and then once we have a uh a","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=150s"},{"start_seconds":158,"text":"partially signed Bitcoin transaction um we call the uh the get","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=158s"},{"start_seconds":166,"text":"signature and so the way that we're doing this with uh Bitcoin JS","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=166s"},{"start_seconds":173,"text":"lib um we need to pass in this key pair and this sign function that calls the near","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=173s"},{"start_seconds":180,"text":"sign function and so this is the uh sign function on near uh it just constructs the uh uh","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=180s"},{"start_seconds":187,"text":"transaction and then it uh calls the uh wallet.com method and so this is what pops up the","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=187s"},{"start_seconds":194,"text":"um uh the near uh web wallet and so that","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=194s"},{"start_seconds":202,"text":"Returns the signature and um once we uh have the","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=202s"},{"start_seconds":209,"text":"signature we call this broadcast function with the uh signature passed in as a parameter and uh then we construct","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=209s"},{"start_seconds":218,"text":"the uh pspt again uh and we pass in a sign function that um already has access","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=218s"},{"start_seconds":225,"text":"to the signature and returns it and um after that we can call psbt finalize all","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=225s"},{"start_seconds":234,"text":"inputs and we broadcast the transaction to uh blockstream which which um propagates the transaction to the","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=234s"},{"start_seconds":242,"text":"Bitcoin Network and uh that's it so that's how you can","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=242s"},{"start_seconds":249,"text":"um build a Bitcoin uh app using um chain signatures uh with every","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=249s"},{"start_seconds":257,"text":"all of the code running in the client and um Edson is going to explain how to do the same thing but with a","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=257s"},{"start_seconds":265,"text":"smart contract hey hi everyone like like GRE","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=265s"},{"start_seconds":274,"text":"mentioned um we can do the same um yeah looking at the architecture of this the app the client is doing basically","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=274s"},{"start_seconds":283,"text":"Gathering the utxo but connecting with the MPC Network to get the signature and then","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=283s"},{"start_seconds":290,"text":"constructing everything in the client side however here we have a different","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=290s"},{"start_seconds":296,"text":"architecture for a d app that is just Gathering the utx SCE but then is communicating with a near","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=296s"},{"start_seconds":305,"text":"contract that internally is calling the MPC contract that is uh connected with a","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=305s"},{"start_seconds":313,"text":"with a couple of uh with the MPC Network so you basically can from the client","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=313s"},{"start_seconds":320,"text":"side simply gather the utx SCE execute a near transaction that is calling a near contract and this near contract will um","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=320s"},{"start_seconds":330,"text":"build the transaction payload connect with the MPC contract get the signature and return everything to the client side","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=330s"},{"start_seconds":339,"text":"that is ready to be broadcast broadcasted to the Bitcoin Network and um yeah that's um we we","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=339s"},{"start_seconds":349,"text":"believe this pattern is very powerful because it could enable more complex logic that is it can generate um","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=349s"},{"start_seconds":357,"text":"basically that is going to be executed Within a new contract now for this um basically you want to start building","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=357s"},{"start_seconds":365,"text":"this type of um contracts we have prepared for you what we call the Omni transaction","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=365s"},{"start_seconds":373,"text":"RS which is basically a library that allows you to create transaction payloads but not only for Bitcoin but","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=373s"},{"start_seconds":382,"text":"also for near and for ethereum inside a new contract you can visit the the","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=382s"},{"start_seconds":389,"text":"repository in uh near SL Omni transaction RS and here we have a a bunch of um yeah","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=389s"},{"start_seconds":398,"text":"a couple of examples but here also we have more elaborated examples for instance for uh Bitcoin","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=398s"},{"start_seconds":406,"text":"encoding Bitcoin signing for legacy and set with transactions and we even include examples of how to propagate","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=406s"},{"start_seconds":414,"text":"that um to a Bitcoin Network and um yeah that's pretty much all","url":"https://www.youtube.com/watch?v=HkuINgDg2X4&t=414s"}],"youtube_url":"https://youtube.com/watch?v=HkuINgDg2X4","url":"https://near-pedia.xyz/videos/HkuINgDg2X4"}