0% found this document useful (0 votes)
9 views

Expn 6

Blockchain practical No 6

Uploaded by

pranayaws15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Expn 6

Blockchain practical No 6

Uploaded by

pranayaws15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment No:-6

AIM: Blockchain application Development with Ethereum.

THEORY:
1. Sol Compiler, Bytecode and ABI
Sol Compiler Solidity is one of the languages that is used to author smart contracts.
Smart contracts will be dealt with in detail in the following chapters. The code written
using Solidity is compiled using a Solidity compiler, which outputs byte code and other
artifacts needed for deployment of smart contracts. Earlier, Solidity was part of the Geth
installation, however, it has moved out of Geth and should be deployed using its own
installation. The Solidity compiler also known as sole can be installed using npm:
npm install -g solc
ByteCode- It is the information that our Solidity code gets "translated" into. It contains
instructions to the computer in binary. Bytecode is generally compact numeric codes,
constants, and other pieces of information. Each instruction step is an operation which
is referred to as "opcodes," which are typically one-byte (eight-bits) long. This is why
they're called "bytecode" one-byte opcodes. Every line of code that is written gets
broken down into opcodes so that the computer knows exactly what to do when running
our code. In the Ethereum world, the bytecode is actually what gets deployed to the
Ethereum blockchain. When we deploy to an Ethereum network and confirm the
transaction using a browser-based wallet like Metamask, we can actually see the
bytecode that gets deployed.

ABI- ABI are basically sets of methods, functions, variables, and constants that you can
use to interact with a library, a network endpoint, a backend service, or other software
services and applications. APls are a way to expose the functionality of a piece of
software in a controlled, stable, and intuitive way. APIs define the ways in which two
pieces of software can interact with each other through an interface. ABIs are
application binary interfaces. They define the methods and variables that are available
in a smart contract and which we can use to interact with that smart contract. Since
smart contracts are converted into bytecode before they get deployed to the blockchain,
we need a way to know what operations and interactions we can initiate with them, and
we need a standardized way to express those interfaces so that any programming
language can be used to interact with smart contracts. While JavaScript is the most
commonly used language for interacting with smart contracts you can interact with a
smart contract using any coding language as long as you have the ABI for that smart
contract and a library to help you communicate with any one node to give you an entry
point into the Ethereum network.

2. What is Ganache?
Ganache Ganache is a personal blockchain for rapid Ethereum and Corda distributed
application development. You can use Ganache across the entire development cycle;
enabling you to develop, deploy, and test your dApps in a safe and deterministic
environment. Ganache comes in two flavors: a Ul and CLL. Ganache Ul is a desktop
application supporting bothEthereum and Corda technology. Our more robust command
-line tool, ganache, is available for Ethereum development.
3.Use of Ganache and its alternative
Use of Ganache - Ganache is used for setting up a personal Ethereum Blockchain for
testing your Solidity contracts. It provides more features when compared to Remix. You
will learn about the features when you work out with Ganache. Before you begin using
Ganache, you must first download and install the Blockchain on your local machine.
Ahernative of Ganache Hardhat is a development environment for testing, deploying.
compiling, and debugging Ethereum-based dApps. This means that, just like Ganache,
Hardhat can help developers with some of the inherent tasks to Web3 development.
Hardhat focuses on Solidity debugging, which makes it ideal for developing
EthereumdApps. As such, the network features some great functionalities such as
Solidity stack traces, automatic error messages, and the Hardhat network.
4. Steps to set up Local Blockchain Application Development Environment.
a. Installing Metamask - MetaMask is a web browser extension that can be installed on
Google Chrome, FireFox, Opera, or Brave. End users can use the extension to interface
with smart contracts. The MetaMask browser extension automatically imports the
Web3 object as global JavaScript variable on every webpage the user visits. It uses the
HTTP provider which is selected in the pictured drop down menu.
b. Installing the Solidity Compiler (solc) - Before you deploy a smart contract to an
Ethereum network (or your localhost), you must first compile it to bytecode. This turns
your program into machine-readable opcodes that Ethereum nodes understand how to
execute. In addition to bytecode, the Solidity compiler also produces an ABI (application
binary interface). This is a JSON object that maps to your bytecode. Web3.js (and other
frameworks) can do JSON RPC using the ABI, and the address of your smart contract.
Think of the ABI as the bridge between Web2 and Web3.
c. Installing Web3.js - Web3.js is a popular library for interfacing with the Ethereum
blockchain. To use it in a web page, you can import the library directly using a CDN like
JSDeliver.
d. Ganache CLI - It is an essential tool for Ethereum development and testing. You can
easily spin-up your own instance of Ethereum on your local machine with 1 terminal
command. When you boot up Ganache, it gives you 10 Ethereum wallets that each
contain 100 fake ETH. You can use this test net ETH to test smart contracts on your
localhost blockchain.
After all the dependencies are downloaded then we are ready to build our first app.
1. Create a directory on your local machine for your DApp project files. You can do this
on the command line.
mkdir first-ethereum-
dapp cd first-ethereum-
dapp/
2. After the directory is ready we are now able to write our smart contract inside the
directory.
3. Compile the written smart contract.
4. Configuring the project and local development environment in which there is a build
folder containing 2 files. One contains the contract bytecode, and the other contains the
contract ABI.
5.Now that we have our own test blockchain running on our local machine, we can
deploy the contract we built carlier. In your first command line window, make a new file
called deploy js And then you can continue creating your first application or website that
is actually working co the blockchain.

Implementation of Smart Contract:


CONCLUSION
Solidity is one of the most important programming languages that has been developed
when it comes to blockchain technology. With the help of the above we are able to learn
about the ganache provider, the environment. Ganache is a personalized blockchain for
Ethereum development.

You might also like