This repository is a tutorial on writing your first decentralized application on RChain. It assumes moderate familiarity with the command line, RNode software, and node.js. I will walk you through building a simple microblogging dapp in a way that you can primarily copy and paste. I encourage you to experiment as we move along. RChain is still in a pre-release state and not all of the features we would have used in this dapp are available yet. When we do have to work around an issue with the current RNode, I do my best to point it out.
Written By: Joshy Orndorff Special Thanks: Dan Connolly
It's nice necessary to know what you're building before you start building it. So you may want to launch the project before we even begin.
- Install RNode (instructions)
- Install node and npm (instructions)
- Clone the repo
git clone https://github.com/JoshOrndorff/Rchain-Status.git
- Change into the project directory
cd Rchain-Status
- Install dependencies
npm install
- Start a fresh, pre-configured RNode
npm run fresh
- Deploy the necessary smart contract to your node
npm run deploy-contract
- Launch the dapp frontend
npm start
- Navigate to the user interface in your favorite browser at
localhost:54321
Before we begin, I'll show you the plan. These are the big-picture steps that you'll need to follow in order to write any dap
- Design the smart contract -- ours is in
status.rho
- Design an interface -- We're using electronJS (soon to be express)
- Connect the interface to the contract -- We'll use the RChain-API node module
- Deploy your contract
- Use your dapp
- Celebrate :)
Our primitive social media Dapp allows users to post a single status message representing their current thoughts, activity, etc. Examples might include "Rainy Saturday...", "Long weekend coming up!", "Go Indians! World series this year!".
I Before they can use the dapp, a user has to register. This rholang code does that.
Insert code (signature, setting default status, returning ack (which happens to also be the OCap)) Insert explanation Insert gui instructions
In reality a user should use an unforgeable name anytime object capabilities are involved. This is the first hack we will employ because the rholang name registry is not yet complete.
One primary feature of such a dapp is to check your friends' statuses. Here's the rholang.
Insert code explanation
Right now the only person we know using the dapp is us, so let's check our own status. In the dapp, enter our name in the friend box, and click check. We see that our status is currently the default status that we got when we registered.
- Node command line utility
- Python utility
If you've followed along until now, you have a complete working version of this same dapp in your project directory. It's time to deploy and test it.
You'll need to grab the package.json
file to make these commands work
Insert deploy instructions again.
I sincerely hope that this guide was helpful and made your path to your first dapp a bit easier. I will continue to improve this guide as new node features are release. I'd also love your feedback
(link or something to submit feedback)