• Uncategorized
  • 0

Writing a DAPP for the Ethereum block chain

Writing a DAPP for the Ethereum block chain

posted October 2017

warning: spil this is a proof of concept to see if 4chan could be implemented on the blockchain, some people might postbode shocking pictures or movies on there. At the time of the writing nothing “bad” has happened, but take precautions if you’re programma to take a look at it 🙂

The FiveMedium DAPP browsed from the Nevel wallet

I’ve bot dabbing ter clever contract security (see my movie here) and I found it natural to attempt and do a DAPP (decentralized application) myself. How hard can it be?

Three.Five days straks I’ve got back into Javascript after many years, I’ve learned Vue.js (zuigeling of, my code is indeed ugly) and I’ve created my very first DAPP!

Very first thing I’ll have to say: it’s hella joy.

Javascript has gone a long way and the Vue.js framework is just fine! I’ve attempted using React but I found it less developer-friendly, tighter to learn and lacking te terms of template. It just didn’t click. I guess coming from HTML very first (and jQuery straks) the Vue.js framework just makes more sense to mij. It’s all about having joy and I wasn’t having any with React.

I still want to create, modify and query things the jQuery way, but I’m getting used to the javascript modernities (querySelector, arrow functions, . ) and the Vue.js way. I like it. It will take some time to get rid of my old habits and re-think the way I write vuurlijn end code but I like it.

Writing the wise contract is fairly straight forward. It’s 128 lines of Solidity code, but most of it are comments (yes I comment my code). At one point I should publish it on etherscan.io because this is best practice. It’s not compiled with the last version of Solidity (boooo!) because I deployed it via Nevel and Nevel doesn’t have the last version of Solidity.

Writing the dapp with Vue.js and the web3.js API (the javascript library to interact with the blockchain via an ethereum knot) is pretty straight forward spil well. The learning curve is not bad and there are tons of resources for beginners. That is, until you test your dapp with a real wallet like the Metamask wallet (integrated spil a browser plugin) or the official Nevel wallet (Electron app). Different wallets offerande different functions and versions of web3 (how it works: they inject the web3 object ter your document and you can use it directly from your javascript webapp). They also (for the most part) reject any synchronous calls on the web3 API without indeed providing ways for you to debug what is not synchronous te your call. A lotsbestemming of functions have to be substituted for the asynchronous variants, any async/await has to vanish and you come in callback hell. Not joy.

The worst is that the documentation gets sparser and sparser spil you inject the world of real DAPPs. You understand that things are switching truly prompt, that wallets will soon zekering supporting web3.js and that a real API will be provided at some point. Everything is way more experimental than I had thought.

On top of that, Metamask doesn’t let you witness for events yet, so say goodbye to your DAPP being “live” for their users.

To make the app offline, meaning browsable without a wallet, I use Infura. You basically just have to switch the url of the knot to the ones Infura gives you, and web3 will be able to interact with it the same way it interacts with a real knot. This is because the standard works via normal Json-RPC routes using the Json way to structure queries and responses. Unluckily, like Metamask, Infura doesn’t let you listen to events so the app is browsable, but not live.

I toevluchthaven’t taken the time to publish the clever contract on the real ethereum network yet. It’s sitting on Rinkeby which is a test network where you can get ethers for free. I’m not going to get rich on a test network, and some of my friends are eyeballing mij for this decision (I see you jc) but this is joy and I want people to attempt it for free 🙂

Is it hard? No but it’s annoying. Very first I need to pull up the entire Ethereum blockchain.

Spil of April 19th, 2017, my blockchain size is 23.Five GB total.

2nd, I need some ethers, and buying ethers from the UK is hard. Of course I already have some (I wouldn’t be writing anything about ethereum if I wasn’t invested), but I had to go through weeks of research to buy them. (If you’re looking for an effortless way, learn from my wasted time: transfer money on a Revolut account, switch it to euro, do a free SEPA transfer to Kritiseren, buy ethers there.)

Anyone can replicate my work. The DAPP is client-side code (javascript) so anyone can download it and run it on their own pagina. the contract is also up there on the blockchain, it’s public stuff. I don’t truly like this, but it is how Ethereum works. If I someday druppel the pagina from the internet, anyone can get it and run it. Run it on their own server, but also run it locally from their own machine.

If you want to see how it works without getting a wallet:

But I recommend you to give a attempt to this fresh technology!

Download Nevel, set the network to Rinkeby, grab some free ethers from the faucet there and browse to my DAPP FiveMedium.

Related movie: Crypto Mining 101 – Multi Pool Mining & Awesome Miner


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *