DEV Community

A Guide to creating TapRoot Scripts with bitcoinjs-lib

Oghenovo Usiwoma on February 19, 2023

Taproot and Schnorr are upgrades to the Bitcoin protocol designed to enhance the privacy, efficiency and flexibility of Bitcoin transactions. Tapr...
Collapse
 
chironjitd profile image
CD

Hi, i'm trying to use the examples below to replicate an ordinals transfer, paid for by another wallet. May i ask how we would extend these examples for taproot transfer from one wallet to another but payment transfer done from one P2SH wallet to another?

Collapse
 
iyg profile image
y

Hello, do you use bitcoinjs-lib to implement taprot addresses for ord inscribe? I can transfer the inscription id now, but I don't know how to create a new inscription(use bitcoinjs-lib)

Collapse
 
chironjitd profile image
CD

Hey y. I have managed to do a transfer using both bitcoinjs-lib and micro-btc-signer. But I'm in the same boat where i'm not certain yet how to do an actual inscription.

Thread Thread
 
iyg profile image
y

Okay, if you have implemented inscribe, can you share some code examples? I am now using this test inscription: github.com/cmdruid/tapscript/blob/...

Thread Thread
 
chironjitd profile image
CD

Noted, will do. Also, thank you for sharing the example code

Thread Thread
 
cani1see profile image
cani1see

did you find how to do the inscribe now, using tapscript or bitcoinjs-lib?

Thread Thread
 
fboucquez profile image
fboucquez

HI @y, @chironjitd , any luck converting the tapscript ordinal example to bitcoinjs? Thanks in advance!

Collapse
 
eunovo profile image
Oghenovo Usiwoma • Edited

Not sure I understand you correctly. You want to transfer UTXOs from one P2SH address to another?

Collapse
 
eunovo profile image
Oghenovo Usiwoma • Edited

@cd if you are trying to work with P2SH, my article on P2WSH dev.to/eunovo/unlocking-the-power-... might help you

Thread Thread
 
chironjitd profile image
CD

Hi Oghenovo, thank you for your reply. I was trying to do an Ordinals inscription transfer, and needed to figure out how to do so.

I can now do a transfer but i feel that my base understanding of taproot is not quite there. Are you planning to write more articles on deep diving into taproot or have suggestions on reading sources?

Thread Thread
 
eunovo profile image
Oghenovo Usiwoma
Collapse
 
nikicat profile image
Nikolay Bryskin

Thanks!

Collapse
 
mariobtc profile image
Mario

Hello Oghenovo!
Thank you for your helpful article and code samples.

In line 30 of you code on github, you tweak the signer and in line 32 you create the address to where the faucet sends the tBTC.

But in the bitcoinjs-lib example starting from line 19, they use an un-tweaked public key for the address generation (line 46).

However, they use a tweaked key to sign the input (line 55).

How does that work? Or did I miss something?
Thank you.

Collapse
 
pagarevijayy profile image
Vijay Pagare

how to import/implemenet toXOnly??

Collapse
 
mint_pz_64c097d566a1c34c0 profile image
mint pz

thanks a lot!