Hey everyone, I posted something like this here not long ago:
I thought this would be an easy job, but wow, was I mistaken. I'm trying to create a Bitcoin inscription using C#. I've come across libraries that handle this in Javascript and a couple of other languages, but nothing for C#. I'm stuck without a solid example. I wrote a script that’s almost there, but I keep hitting a signature error.
Just to clarify, I’m aware that making Bitcoin inscriptions or anything that resembles an ordinal or BRC-20 can spark some debate, but that’s not my aim. The goal is to make an inscription for an app that only needs a TINY bit of "hard" storage in the form of an inscription. We're talking about something SUPER SMALL (like the size of a sha-256 hash) that won’t congest the Bitcoin network. Still, I can't find anyone to help me sort out the bug in my script. Is there anyone who knows how to tweak my C# code to work like my Javascript one?
C# Bitcoin development with tapscript feels impossible
6 replies 182 views
Since you only want to include output of SHA-256 hash (which have size 256-bit or 32-byte), you better use OP_RETURN. I didn't do any research, but i expect there should be C# library which let you create Bitcoin TX with OP_RETURN support since OP_RETURN has been around for 10+ years.
I already know about OP_RETURN, but unfortunately I can't use it for this project. The app requires the string to be read with the ordinal envelope aka:
But obviously instead of "Hello world!", it will be the SHA256 hash. I'm taking advantage of an ordinal block explorer to by giving the envelope the ordinal identifier "ord" so the SHA256 hash is picked up on the ordinal block explorer where my app can read the hash.
Even though I am using the ordinal envelope and using an ordinal block explorer to read the data, this is not an ordinal in a traditional sense. Every user on my app will write 1 ordinal as a registering function for my app. It will not clog up the bitcoin blockchain and will not spam the bitcoin network. Gas fees will not go up because of my app, don't worry.
So does anybody know how to fix my C# script so it works like my Javascript script does?
Bitcoin blockchain is not meant for data storage and Bitcoin is not a cloud storage. It is a payment system and the blockchain is ledger for monetary transactions. So it doesn't matter if it is 1 byte or 1 terabyte that you are injecting into the chain by using the exploit in the protocol, it is still abusive.
So use OP_RETURN instead as @ABCbits said or better yet use one of those data-storage altcoins. There are a couple of them that are created for this exact purpose.
Have you verified that your transaction creation functions are working fine for other types of transactions and that it is just the TapScript code that's causing errors?
Yeah I have a more complex version of each script that creates the inscription address, I send a BTC transaction to that address, then the script spends the UTXO that I sent the address. The Javascript scripts works perfectly and creates an inscription when I spend along the script path of the freshly created address. The C# script fails with a signature error when I try to spend from the script path of the freshly created address.
My C# script works fine spending along the address keypath, but not the script keypath. Looking at the output transactions from the Javacript script and C# script, I've narrowed it down to the the tapscript not being created correctly in the C# script.
And regular block explorer can show OP_RETURN data.
Bitcoin user will be impacted if your application is popular enough. And if your application is centralized, i don't understand why you chose not to use either email address or phone number.
Related topics
- Ways to earn some sats by contributing to bitcoin core development 5
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3
- Exploring the Potential and Challenges of a Kardashev-Scale Bitcoin Network 3
- What can I do to fix this Bitcoin Core error? 8