your first application for ethereum (Dapp)

in #ethereum8 years ago (edited)


A while ago i was looking to make a dapp and found a lot of information , unfortunately all the information I found was split , after much research I was finally able to create a simple Dapp , I gave up like 5 times but eventually achieved what I wanted.

Introduction

First of all just show you how to create a super- simple dapp and how to connect to a node .This is the first part of the application and will only be essentially,  later I teach you how to create the gui of dapp to interact with it, well let us begin.

1.- Install node.js

windows : 

go to the page https://nodejs.org/en/download/ , click in windows installer, then install, and that's all.  :/

mac :

The same as windows .

Linux (ubuntu/debian):

Good we got to the interesting part, ubuntu comes with node installed by default, but has a very old version and no more upgrade in its main repository, If you found the old Node package installed, run this command to completely remove it:

sudo apt-get remove --purge node

then

apt-key adv --keyserver keyserver.ubuntu.com --recv 68576280
apt-add-repository 'deb https://deb.nodesource.com/node_4.x precise main'
apt-get update
apt-get install nodejs

2 .- install geth (ethereum node)

This step is important , you must install the node ethereum to work our Dapp ,You can find the installation steps on the official website of ethereum but anyway I'll tell you how to install it .

Windows (64 bits):

Just follow the link and install the program.

https://build.ethdev.com/builds/Windows%20Go%20develop%20branch/Geth-Win64-latest.zip 

Linux : 

There are several ways to install on Linux , can be direct  downloading or by repository.

Direct : https://build.ethdev.com/builds/Linux%20Go%20develop%20deb%20i386-trusty/latest/

Tutorial for PPA: https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu

MAC:

Direct Link : http://build.ethdev.com/builds/OSX%20Go%20develop%20branch/Mist-OSX-latest.dmg

3 .- Install web3.js (client Java Script)

web3.js is the client with which we will make our Dapp , this library will allow us to communicate with the node ethereum.Creates a directory in your file folder where you want to go your Dapp.

Put on your console this code to install the library

npm install web3


4.- initiating Dapp

in our project folder we create a file called main.js which contain the code of our Dapp. First thing to do is call the web3.js.

var Web3 = require('web3');


then the object must define and connect the node , we do as follows.

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

then check if he connected correctly.

if(!web3.isConnected()) {
console.log("connected"); 
} else {
console.log("not connected")
}


now we run from the console with the following command.

node main.js


I appear not connected to us because we have not started the node ethereum.

5.- starting the ethereum node

Once installed geth put this code in the console.

geth --rpc

The node of ethereum was started and synchronized , maybe take a while synced.We run our main.js and see that tells us connected, and that's it , we have the beginning of our Dapp , you can check your balance , make transactions and more.


To assign a address to our Dapp is with the following code.

web3.eth.defaultAccount = "YOUR_WALLET_ADDRESS";
var defaultAccount = web3.eth.defaultAccount;
console.log(defaultAccount); 


I hope you liked it , excuse my bad English , and if in doubt do not hesitate to ask , leave web3.js full documentation and installation of geth . Thanks for reading me :).

web3.js : https://github.com/ethereum/wiki/wiki/JavaScript-API

geth : https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum


Dapp

Sort:  

Great article. I am not technical and dont know anything about dapp creation. I did, however, spend a few days and went through every coin on coin market cap and compiled a list of Dapps that are in production. https://steemit.com/cyrptocurrency/@herronryan/the-dapp-list-100-decentralized-products-available-now

Wow, this is an amazingly informative article! It's inspired me to try and create my first DAPP!

Check out my latest blog post on a DAPP known as Birdchain. It's users will be able to earn a monthly passive income!

https://steemit.com/cryptocurrency/@mikerowave/birdchain-a-decentralized-app-with-a-difference

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 60192.33
ETH 2321.67
USDT 1.00
SBD 2.50