0% found this document useful (0 votes)
12 views7 pages

BCT 4-6

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

BCT 4-6

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

DEPARTMENTOFARTIFICIALINTELLIGENCE&DATASCIENCE

Subject: Blockchain Technologies Course Code: CSDOL7022


Semester: 7 Course: AI&DS
Laboratory no.: 101 Name of subject teacher : Prof. Devita Ghanekar
Name of student: Rugved Patil Roll no: VU2S2223001

Experiment No. 4

Title: Embedding wallet and transaction using Solidity

Theory:

Smart Contract
A smart contract is a self-executing digital contract with the terms of the agreement directly written into code.
It automatically enforces and executes the contract once the predefined conditions are met. Smart contracts
run on decentralized blockchain networks like Ethereum, ensuring transparency, security, and immutability.
These contracts can handle transactions, agreements, or any automated workflow without needing
intermediaries, reducing costs and increasing efficiency.

Compiling Smart Contracts


When you write a smart contract in Solidity, it needs to be compiled into bytecode that can be executed by the
Ethereum Virtual Machine (EVM). In the Remix IDE, you can compile the contract by clicking the Solidity
Compiler tab and then the Compile button.
The compiler checks for syntax and logic errors in the code and generates the bytecode necessary for
deployment. This bytecode is the representation of your contract that the blockchain can understand and
execute. Additionally, the compiler will provide an Application Binary Interface (ABI), which defines the
contract’s interface for interacting with its functions.
Deploying and Running Smart Contracts
Once the contract is compiled successfully, you can deploy it to a blockchain network (either a local blockchain,
testnet, or mainnet). In Remix, deployment can be done through the Deploy & Run Transactions panel. After
deploying the contract, the contract is given an address on the blockchain, and users can interact with its
functions by calling them through the blockchain’s interface.

Debugging and Running Smart Contracts


Running a smart contract involves testing its functionality by interacting with it on the blockchain. However,
bugs can arise due to logic errors, unexpected user inputs, or even external factors like gas limits.
Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Transactions {

// Event to notify when Ether is sent


event MoneySent(address indexed receiver, uint amount);

// Function to send Ether to a specified address


function sendMoney(address payable _receiver) public payable {
require(msg.value > 0, "Send some Ether to execute this transaction");

// Transfer the Ether to the receiver


_receiver.transfer(msg.value);

// Emit an event for the transfer


emit MoneySent(_receiver, msg.value);
}

// Function to check the balance of a specified address


function checkBalance(address _address) public view returns (uint) {
return _address.balance;
}
}

Conclusion: Thus, we have embedded wallet and transaction using Solidity.

R1 R2 R3
DOP DOS Conduction File Record Viva -Voce Total Signature
5 Marks 5 Marks 5 Marks 15 Marks
DEPARTMENT OF ARTIFICIAL INTELLIGENCE
&
DATA SCIENCE

Subject: Blockchain Technologies Course Code: CSDOL7022


Semester: 7 Course: AI&DS
Laboratory no.: 101 Name of subject teacher : Prof. Devita Ghanekar
Name of student: Rugved Patil Roll no: VU2S2223001

Experiment No. 5

Title: Blockchain platform Ethereum using Geth.

Theory:
Ethereum is run by different clients on different peoples’ computers. Whether you’re using a C++, Rust,
Golang, or some other implementation doesn’t matter so long as your client implements the protocol properly.

Installing
Geth brew update brew upgrade brew tap ethereum/ethereum brew install ethereum Now you have Geth
available to you on the command-line.

Creating an Account
You need to create a private/public keypair first so you can write transactions to the blockchain. You do this in
Geth with the following command (note: do not forget the passphrase you choose).

You can see your account by running:

The genesis.json file:


The genesis file determines two things: what will take place in the genesis block, or the first block of your
blockchain, and also the configuration rules your blockchain will follow. I wrote a detailed writeup about how it
works and every field in the genesis.json file: Deep Diving into the Ethereum Genesis State File.

Conclusion: Thus, we have studied Blockchain platform Ethereum using Geth

R1 R2 R3
DOP DOS Conduction File Record Viva -Voce Total Signature
5 Marks 5 Marks 5 Marks 15 Marks
DEPARTMENT OF ARTIFICIAL INTELLIGENCE
&
DATA SCIENCE

Subject: Blockchain Technologies Course Code: CSDOL7022


Semester: 7 Course: AI&DS
Laboratory no.: 101 Name of subject teacher : Prof. Devita Ghanekar
Name of student: Rugved Patil Roll no: VU2S2223001

Experiment No. 6

Title: To study and install Blockchain platform Ganache

Theory:
Ganache
Ganache is a personal blockchain for Ethereum development that allows you to deploy contracts, develop
applications, and run tests on a local blockchain environment. It is part of the Truffle Suite and is available as
both a GUI and CLI tool. Here's what Ganache provides:
1. Local Ethereum Blockchain: Ganache creates a local Ethereum network on your machine. This allows
you to quickly test your DApp without relying on public testnets or spending real Ether. You can control
the environment, including block times and gas limits.
2. Pre-configured Accounts: Upon starting Ganache, you receive several pre-configured accounts loaded
with fake Ether. These accounts are useful for testing the sending of transactions and deploying
contracts without needing to worry about funds.
3. Blockchain Simulation: Ganache simulates Ethereum’s mainnet, but since it runs locally, it's much
faster. It provides detailed logs of all transactions, including gas costs, making it easy to debug and
optimize your contracts.
4. Time Travel Feature: You can manipulate the blockchain time to test how your smart contract behaves
in the future or past, which is useful for contracts that depend on time-based logic.

Installation:
 Download Ganache:
Go to the Ganache releases page on the Truffle Suite website.
Run the downloaded installer and follow the prompts.
 Open Ganache:
After installation, launch Ganache from the Start Menu or desktop shortcut.

Conclusion: Thus, we have studied and installed Ganache.

R1 R2 R3
DOP DOS Conduction File Record Viva -Voce Total Signature
5 Marks 5 Marks 5 Marks 15 Marks

You might also like