Ever had a multi million dollar idea? Did it involve BitCoin, smart contracts, blockchain or crypto currencies?
A lot of people had that dream, but where do you start? We are going to take a quick peek into how to get started with Ethereum dapps (distributed applications) in JavaScript.
We will look into what you will need to get started.
To create an Ethereum web app (dapp) using JavaScript, you can/will need to use these technologies and tools:
-
Ethereum client: You can use either Ganache which is a local Ethereum node or connect to a remote Ethereum node like Infura or others.
-
Web3.js library: This is a JavaScript library that provides an API for interacting with Ethereum nodes.
-
Solidity smart contracts: Smart contracts are written in the Solidity programming language and are deployed to the Ethereum network.
-
MetaMask: A browser extension that allows users to interact with Ethereum dapps from their browser.
​
Let's go over the steps to create an Ethereum web app using JavaScript:
-
Set up your dev environment: Install Node.js, Truffle, and Ganache or connect to a remote node like Infura.
-
Create a new project directory and run the command `npm init` to initialize a new Node.js project.
-
Install the Web3.js library by running the command `npm install web3`.
-
Write a Solidity smart contract and compile it using the Truffle framework. Learn how to write smart contracts.
-
Deploy the smart contract to the Ethereum network using Truffle.
-
Create a new HTML file and add the Web3.js library script tag.
-
Connect to the Ethereum network using Web3.js and retrieve data from the deployed smart contract.
-
Use HTML and JavaScript to create a user interface for your dapp.
-
Use MetaMask to interact with the dapp from your browser.
This is an example of how the starter code can be:
This code connects to a local Ethereum node running on port 7545, retrieves a deployed contract instance using its address and ABI, and calls a function on the contract. You can use the returned result to update your dapp's user interface.
Okay, so many new words to learn. Truffle, Ganache, Web3 and Smart contracts.
Yes it might be a lot in the beginning, but we will try to go trough some of it. So what is a smart contract?
​
A smart contract is a self-executing computer program that automatically enforces the terms of an agreement between parties. It is a piece of code that runs on a blockchain network, such as Ethereum, and is immutable, meaning it cannot be altered once it has been deployed.
​
Smart contracts are designed to facilitate, verify, and enforce the negotiation or performance of a contract. They can be used in a wide variety of applications, from financial transactions and supply chain management to voting systems and digital identity verification.
​
Smart contracts are written in programming languages such as Solidity, Vyper, or Rust, and are compiled into bytecode that can be executed on the blockchain. They contain the rules and conditions that govern the interactions between parties, and can be programmed to automatically execute specific actions when certain conditions are met.
​
Smart contracts are executed by nodes on the blockchain network, and once a contract has been deployed, it becomes a permanent part of the blockchain. This means that smart contracts are tamper-proof and transparent, as anyone can view the code and the history of transactions on the blockchain.
​
Smart contracts have several advantages over traditional contracts, including:
-
Trust: Smart contracts are executed automatically and transparently, without the need for intermediaries, which increases trust between parties.
-
Efficiency: Smart contracts can automate the execution of complex agreements, reducing the need for manual intervention and streamlining processes.
-
Security: Smart contracts are tamper-proof and cannot be altered once they have been deployed, which reduces the risk of fraud or manipulation. So pretty secure.
-
Cost-effectiveness: Smart contracts eliminate the need for intermediaries, which can (or it can cost you more) reduce costs associated with traditional contract execution.
​
Overall, smart contracts have the potential to revolutionize the way we conduct business, by creating a more efficient, secure, and transparent way to execute contracts and agreements. If you can automate something while it's also secure and trustworthy, then smart contracts might be the solution for your idea.
​
Are there any tools to help developers making smart contracts. Yes there is, and Truffle is one of them, and maybe one of the more popular once also.
​
Truffle was initially released in 2015 and has since become one of the most widely used development frameworks in the Ethereum ecosystem. It is open source and has a large and active community of developers who contribute to its development and maintenance.
Truffle is a development framework for Ethereum smart contracts. It provides a suite of tools and utilities that make it easier to develop, test, and deploy smart contracts on the Ethereum network.
​
Key features of Truffle include:
-
Smart contract compilation: Truffle provides a built-in Solidity compiler that allows developers to compile their contracts into bytecode that can be deployed to the Ethereum network.
-
Contract deployment: Truffle provides a deployment tool that makes it easy to deploy contracts to the Ethereum network.
-
Testing framework: Truffle includes a testing framework that allows developers to write and run tests for their smart contracts. Good to have when you need to debug or improve your contracts.
-
Contract management: Truffle includes a contract management system that makes it easy to manage multiple contracts and their dependencies.
-
Network management: Truffle provides a network management tool that allows developers to connect to different Ethereum networks, such as the mainnet, testnets, or local nodes.
Truffle also integrates with other tools and platforms in the Ethereum ecosystem, such as Ganache (a local blockchain network for Ethereum development), Infura (a remote Ethereum node provider), and Metamask (a browser extension for interacting with Ethereum dapps).
​
But Truffle sounds like a made up name, like a joke. is people really using it to make dApps with?
Yes, there are several famous dApps that has been using Truffle for building their decentralized applications (dapps) on the Ethereum network.
Here are a few examples:
-
Augur: Augur is a decentralized prediction market platform built on the Ethereum network. It allows users to create and trade in prediction markets on a wide variety of topics, including politics, sports, and finance.
-
Gnosis: Gnosis is a prediction market and decentralized exchange platform built on the Ethereum network. It allows users to create and trade in prediction markets, as well as trade in a wide variety of digital assets.
-
CryptoKitties: CryptoKitties is a popular collectibles game built on the Ethereum network. It allows users to breed, collect, and trade virtual cats using Ethereum-based tokens.
-
MakerDAO: MakerDAO is a decentralized finance (DeFi) platform built on the Ethereum network. It allows users to create and trade in stablecoins, which are cryptocurrencies that are pegged to the value of a specific asset, such as the US dollar.
-
Uniswap: Uniswap is a decentralized exchange platform built on the Ethereum network. It allows users to trade in a wide variety of digital assets without the need for an intermediary.
So there you have it! This is what you need to get started for your blockchain multi million dollar adventure. Go make those dApps!
​