I'm the founder of read.cash and I'm here to tell you something about development using Bitcoin Cash. Me and my small team have been developing read.cash for 9 months (and before that I've spent 1 year developing Taskopus project with another team - kind of like MTurk on Bitcoin Cash) and after all of that I can say that development using Bitcoin Cash is still unnecessarily hard.
If you compare the onboarding experience of Stripe to that of Bitcoin Cash, its not even in the same league.
So, we want to improve this situation. Below is our idea of experience that will simplify development, ease onboarding of new developers and let them build their new ideas and really boost the ecosystem.
If you are an investor and not a developer, you can skip this part and read directly what we offer and look for.
To get started using Bitcoin Cash on your site, include this tag in your <head> section:
Now, you can create a test wallet:
const wallet = new TestNetHdWallet('buyer');
buyer is an optional name for the wallet, it saves data in user's browser for future re-use
TestNet is where you test your application. TestNet money has no price. Opposite of TestNet is MainNet, which is what people usually mean when they talk about Bitcoin Cash network.
We will need some test money to move around, so lets ask the network for it:
Let's create another wallet and send some of our money there:
const seller = new TestNetHdWallet(); await wallet.send([[seller.depositAddress(), 0.01, 'USD']]);
Let's print the balance of the seller's wallet:
console.log(await seller.getBalance('USD')); // 0.01
Great! You've just made your first transaction!
By the way, this tutorial is also available in our video tutorials section:
Let's say you want to display a QR code for you user to pay you money and show an alert when money arrives?
<img style="display: none" id="qrcode"></img>
document.querySelector('#qrcode').img = seller.depositAddressQrCodeBase64(); document.querySelector('#qrcode').style.display = 'inline-block'; await seller.waitForTransaction(); alert('Transaction has arrived!');
Alternatively you can register a WebHook:
await webhook.register(seller.depositAddress(), 'transaction:in', 'https://mysite.com/api/webhook');
When a transaction to this address comes, you'll be notified with a HTTP POST request to the specified address (that's what
transaction:in is about, you can also use
Ok, as a seller, we are pretty concerned with people knowing how much money we have in our balance (since blockchain is public), so let's obfuscate our money by mixing it randomly with other people's money:
await seller.cashShuffle(); console.log('Your money is now safe from prying eyes!');
Now, no one knows how much money you have or where it came from!
So, now as a seller, we want to buy some goods from
manufacturer, but we don't really trust this guy.
Let's create a blind escrow contract with him, so that only if he fulfills his obligations we will release his money.
We'll need help from a third guy named
arbiter in case we disagree.
Blind escrow contract is absolutely safe for all sides. It is non-custodial, meaning that arbiter never holds the money, they can only send it to the seller (completing the transaction) or back to the buyer (refund). See here for details.
// initialize manufacturer and arbiter wallets const manufacturer = new TestNetHdWallet(); const arbiter = new TestNetHdWallet(); // create the contract const escrow = arbiter.contracts.blindEscrow.create( seller, manufacturer, [0.01, 'USD'] ); // send some money to the contract seller.send([[escrow.depositAddress(), 0.01, 'USD']]);
Let's save our contract (usually, in the database, but we'll save it in a string) to use it later:
const escrowString = escrow.toString();
The manufacturer did not fulfill our order and the arbiter issues a refund (recovering the contract from our storage):
Great! You have your money back and head to Yelp to leave a scathing review about the
Well, let's prrrrrrint some of our own money!
Bitcoin Cash has a way to create your own money out of thin air. It doesn't mean you'll be instantly rich, but these so called "tokens" can be useful for many things, like loyalty points for your customers.
So, a guy called Jerry just made an order and you want to give him 100 loyalty points that he can then spend:
Let's print (mint) our money first
const token = await seller.slp.mint('Loyalty token', 'LTK', 1000);
Nice! You've created a token and can give 3 tokens to Jerry:
const jerry = new TestNetHdWallet('jerry'); await seller.slp.send([jerry, [3, token]]);
Now, Jerry can pay you $10 for his next buy and use his token to get a discount of $1:
await jerry.slp.send([ [seller.depositAddress(), [9, 'USD']], [seller.slp.depositAddress(), [2, token]], ]);
Do you want to create collectibles, like CryptoKitties or on-chain art? Read on how to use .
Bitcoin Cash is volatile, meaning that it's exchange rate varies wildly. As a seller, I want to secure my money and store them in USD equivalent (which is USHD token). It's pretty easy and takes less than a minute.
await seller.sideshift.exchange([1, 'BCH'], seller.slp.depositAddress(), 'USDH');
After about a minute seller will get USDH tokens to his wallet, approximately of the value of 1 BCH that he sent. USDH token value doesn't fluctuate.
Also note that typically when sending SLP tokens you need to send a small amount of BCH along, but thanks to our Post Office protocol integration you can send some tokens (USDH, Spice) without using BCH at all!
If you want something more advanced, but totally on-chain, try using our integrated SWaP protocol exchange:
// seller offers to sell 1 BCH for USDH on-chain const offer = await seller.swapProtocol.signal([1, 'BCH'], seller.slp.depositAddress(), 'USDH'); // buyer finds the offer const foundOffers = await buyer.swapProtocol.watch('BCH', 'USDH'); // buyer agrees to the offer await buyer.swapProtocol.pay(foundOffers);
Impressive? Wait until we tell you how easy it is to both protect your assets and bet on Bitcoin Cash raising in price (long) using our AnyHedge integration:
const offer = await seller.anyHedge.hedge([1, 'BCH'], 'USD', '3:1', '5 days from now'); await buyer.anyHedge.long(offer);
Now, if 5 days from now Bitcoin Cash rises in value -
buyer will get a big 3:1 payout, while
seller has protected the value of his Bitcoin Cash for 5 days and doesn't care if its price
goes up or down, it will still be the same value 5 days from now. All of this is done on-chain and non-custodial,
meaning no exchange can steal your money. (It's not quite as easy, since you need to find a matching counter-offer,
If you pushed any of the buttons above, you can guess that something is wrong here. Yes, nothing described above exist yet.
The technologies that we refer to do exist and are working, but the integration, documentation and simplicity is not there. (We might even be wrong about how some stuff above should work, but bear with us)
Wouldn't it be nice if this was just like described? A few lines of code and you get something as complex as blind escrow contract working?
Think of how many new applications, games, sites using Bitcoin Cash that can spur!
If there was a way for a new reasonably competent programmer to join the Bitcoin Cash ecosystem like that, in a few minutes? Just like when you join Stripe - few lines of code and you are ready to accept credit cards.
Unfortunately, it's not that simple. Current state of Bitcoin Cash libraries is a bit disappointing.
The step where you connect to the TestNet? Disappointing, because TestNet doesn't work at times
The step where you get satoshis for testing? You need to find the faucet, it doesn't work at times. Most of the wallets don't support TestNet and TestNet support in libraries is severely lacking, so most of the time you have to use MainNet with real Bitcoin Cash for testing.
Step where you easily send SLP tokens? Pretty hard still - you need to use multiple libraries and servers, which are down at times. Error messages are cryptic, minute details are everywhere. I'm not even sure if there are some necessary SLP token services on the TestNet.
I'm the founder of read.cash (proof). It is a site that uses Bitcoin Cash. I've been developing using Bitcoin Cash for years and yet I still struggle to do even the most common tasks, let alone things like SLP tokens or escrow contracts. I (and my team) want to use a lot more of Bitcoin Cash functionality, but it's hidden and often very hard to use.
I want Bitcoin Cash development to be really simple. Newcomers shouldn't be dealing with HDNodes, derivation paths, calculating miners fees, compiling blind escrow contracts by hand... To kickstart Bitcoin Cash development all these things should be as trivial as this:
wallet.send(address, [10, 'USD'])
There is already a library that does something similar (bitcash), but it's for Python and it stops at that - sending money. I want to integrate all available Bitcoin Cash technologies and make it more or less language-agnostic (so that it runs inside of browser, in node.js server, and using REST calls in Python, in PHP, in Go, etc...)
Right now when developing, you are bombarded with minute details, like private keys (the library can store it without my knowledge), having to reverse hex strings, need to install multiple libraries to do simplest tasks, sometimes even servers... Like, you can't even send 0.1 BCH simply, you need to calculate the miners fee manually!
This is sadly the state of Bitcoin Cash programming. Anyone who tries to figure out how to do some simple things like creating and sending an SLP token has to go through a lot of docs and will probably give up. I did give up on SLP tokens - still have to idea how to use them
The irony here is that I wrote a detailed article "How SLP tokens work" which was verified by SLP developers that my understanding is correct. I know almost every detail about how they work, I still can't use them. What do we expect from newcomers?
Also, video tutorials are pretty important. People learn better when they can see every step in action with explanations:
We all know that developers are really important! One great developer can create something as great as CryptoKitties or Pokemon Go using Bitcoin Cash and that will explode the whole Bitcoin Cash ecosystem.
With that, we want to make everything described a reality. Not only that, but we want to add all the technologies available, no matter how hard it is to use now, like CashShuffle, AnyHedge, CashChannels, CashScript/Spedn, blind escrow contracts, CashID, Reusable Payment Codes, CashAccounts, CashFusion (if possible), memo/member protocol...
Tons of stuff, very inaccessible at the moment.
But this requires money, of course. Just like everything in our world.
We're not ones who give away money easily, we're pretty thrifty actually, having given away just $6300 on read.cash we have allowed 5000+ users to actually use Bitcoin Cash... But developing this stuff will not be cheap.
You can't hire cheapest developers to create such a library and infrastructure for it. Video tutorials requires voice talents and editing. Servers are needed to host libraries, administrators are needed to take care of servers. Translators are necessary to make this accessible to at least English and Chinese users (hopefully for more users).
Our back of the napkin estimation shows that for such project to succeed, we would need to collect at least 750 BCH (~$175,000)
If you hold big amounts of Bitcoin Cash it is in your best interests to invite new users to Bitcoin Cash ecosystem. Let's say that you have $1M in Bitcoin Cash and invest $10K in this project. After it's done, Bitcoin Cash price increases just 5%, so now your $1M is $1,050,000 - you got $50K investing $10K. In reality what we do might make BCH 10x over time, so even your $100K investment might turn your $1M into $10M.
If you don't have a lof of Bitcoin Cash, but believe in the future of it - it's also your chance to show your support. Everything we do for this money will be released as open source MIT licensed software (free even for commercial use), so it will be accessible to everyone in every language.
Where is the guarantee that we won't take this money and run? Well, first of all, read.cash fund is about $100,000 and even though it's non-custodial - only our honesty stops us from pushing a bad code that would take everyone's money and run. We haven't done it, because a) we're honest and b) we believe in Bitcoin Cash.
We believe that by making Bitcoin Cash accessible for masses we could potentially create 50x-100x inflow of users. If somebody creates some CryptoKitties/PokemonGo type thing that would explode the value of Bitcoin Cash that we hold (unlike some other cryptocurrencies followers, we do hold and use BCH as money).
Also, knowing that it's not our money, we promise to publish transparency reports about how money is used.
The majority of money would be used to finance developers (anyone who can contribute is welcome!). Developers are really expensive - $100,000/year is not unheard of in developed countries. Which means that the amount we're looking for is about two developer-years. It's not enough, of course, to compete with some bigger crypto-projects that got billions in funding and therefore millions for education of new develoeprs. But it's a good start. We won't use all of it on developers, though.
We need some infrastructure too - servers to host and test this stuff, continuous deployment pipeline that ensures that we don't release something that breaks people's sites, we need voice actors and editors to create video tutorials (hopefully there will be enough for that) and we plan to spend some on attracting outside developers to come and try programming with Bitcoin Cash. Probably we'll need something for code audits too.
We will also need to donate some amounts to people running servers (like Electrum Cash servers or fountainhead.cash guys), who provide the infrastructure that this code will use, so that they keep this running.
Initally, we wanted to create a funding platform based on blind escrow contracts (and we actually did, see here), but after getting quite a few cents stuck in some contracts (which is an excellent point why we must have an easier experience for developers) we decided to use Flipstarter for this.