Final-soc-Ethereum-G5111
Final-soc-Ethereum-G5111
(Autonomous)
REPORT ON
ADVANCED SKILL ORIENTED COURSE
Roll. No : 21JR1A12G5
Department
Of
Information Technology
1
KKR & KSR INSTITUTE OF TECHNOLOGY AND SCIENCES
(Autonomous)
(Accredited by NAAC with Grade “A” and Affiliated to JNTUK-Kakinada)
Vinjanampadu, Vatticherukuru Mandal, Guntur,A.P.-522017
CERTIFICATE
Signature Signature
Faculty In charge Head of the
Department
Examiner
2
(Place your certificate here……………..)
3
Vinjanampadu (V), Vatticherukuru (M), Guntur (DT), A.P-522017
DECLARATION
NURBASHA NAGABABU
(21JR1A12G5)
ACKNOWLEDGEMENT
We are very much thankful to the college management for their continuous
support and facilities provided.
We render our deep sense of gratitude to Dr. P. BABU, Principal & Dr. K
Hari Babu, Academic Director, for permitting us to carry out Skill Oriented
course ETHEREUM. We would like to express our sincere thanks to Information
Technology. staff for lending us their time to help us and complete the work
successfully.
We would also like to thank our staff, parents and friends for their enduring
encouragement and assistance whenever required.
NURBASHA
NAGABABU
(21JR1A12G5)
5
KKR & KSR INSTITUTE OF TECHNOLOGY AND SCIENCES
(Autonomous)
Mission:
To incorporate benchmarked teaching and learning pedagogies in
curriculum.
To ensure all round development of students through judicious
blend of curricular, co-curricular and extra-curricular activities.
Mission:
Strengthen the Core Competence through the state-of-the-art
concepts in a congenial Environment.
Promote innovation research and development for the application
of IT to the Economic, Social and Environmental users.
Inculcate professional behaviour, lifelong learning and strong
ethical values to meet the challenges in Information Technology.
Establish centers of excellence in leading area of Information
Technology.
6
7
List of Experiments
SLNo Name of Experiment Page no
1 Create a simple solidity contract that prints “Hello world”. 6
2 Develop a basic ERC-20 token smart contract, including 7 - 8
functions for transfer, balance, and approval.
3 Design a simple ICO contract that allows users to buy 9 - 10
tokens and the owner to withdraw funds.
4 Build a voting contract where users can submit and vote on 11 - 12
proposals , implements safeguards to prevent double
voting.
5 Create a escrow smart contract that holds funds until 13 - 14
predefined conditions are met.
6 Construct a wallet contract that allows funds to be locked 15 -16
until a specified time.
7 Implement a multi-signature wallet that requires multiple 17 - 18
parties to approve transactions.
8 Deasign a simplified decentralized exchange where users 19- 20
can trade tokens.
9 Create a basic NFT contract ,allowing the minting and 21 - 22
transferring of unique tokens.
10 Develop a lottery contract with an entry fee and 23 - 24
randomized winner selection.
11 Build a supply chain contract that tracks the movement of 25 - 26
goods from producer to consumer.
12 Build a contract that verifies user identify using KYC 27 - 28
principles.
13 Develop a contract for subscription-based services , 29 - 30
enabling users to pay on a recurring basis.
14 Design a contract that allows users to stake tokens in 31 - 32
returns for rewards.
15 Design a contract that allows users to purchase pets from 33 - 34
the shop.
8
Activity - 1
Problem Statement: Hello World Contract
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract HelloWorld {
string public greeting = "Hello, World!";
Output:
9
Activity - 2
Problem Statement: Token Creation
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
value);
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
10
Output :
11
12
Activity - 3
Problem Statement: ICO Crowdsale
Design a simple ICO (Initial Coin Offering) contract that allows users to
buy tokens and the owner to withdraw funds.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleICO
{ address public
owner; uint256 public
tokenPrice; uint256
public totalTokens;
uint256 public
tokensSold;
mapping(address => uint256) public balances;
13
balance = address(this).balance;
payable(owner).transfer(balance);
emit FundsWithdrawn(owner, balance);
}
}
14
Activity - 4
Problem Statement: Voting Contract
Build a voting contract where users can submit and vote on proposals.
Implement safeguards to prevent double voting.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
15
keccak256(abi.encodePacked(proposal))) {
return true;
}
}
return false;
}
}
16
Activity - 5
Problem Statement: Escrow Contract
Create an escrow smart contract that holds funds until predefined conditions
are met.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract
SimpleEscrow
{ address public
payer; address
public payee;
uint256 public
amount;
bool public released;
constructor(address _payee)
{ payer = msg.sender;
payee = _payee;
}
17
function release() public { require(msg.sender == payee,
"Only the payee can release funds"); require(amount > 0,
"No funds to release"); require(!released, "Funds already
released");
released = true;
(bool success, ) = payable(payee).call{value: amount}("");
require(success, "Transfer failed");
emit FundsReleased(payee, amount);
}
}
18
Output:
19
Activity - 6
Problem Statement: Wallet Contract
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TimelockWallet {
address public owner;
uint256 public
releaseTime;
uint256 public balance;
constructor(uint256 _releaseTime)
{ owner = msg.sender;
releaseTime = _releaseTime;
}
20
}
Output:
21
Activity - 7
Problem Statement: Multi Signature Wallet
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract
MultiSigWallet
{ address public
owner; address
public signer1;
address public
signer2; address
public signer3;
22
msg.sender == signer3, "Not authorized");
require(address(this).balance >= value, "Insufficient
balance");
to.transfer(value);
emit Transfer(to, value);
}
}
Output:
23
Activity - 8
Problem Statement: Decentralised Exchange
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleDecentralizedExchange
{ address public owner;
uint256 public tokenBalance;
constructor()
{ owner =
msg.sender;
}
24
tokenBalance += tokenAmount;
emit TokensPurchased(msg.sender, ethValue, tokenAmount);
}
payable(msg.sender).transfer(ethValue);
Output:
25
Activity - 9
Problem Statement: NFT Contract
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract BasicNFT
{ string public
name;
string public symbol;
struct Token
{ address owner;
string tokenURI;
}
26
Token[] public tokens;
mapping(uint256 => address) public tokenOwners;
27
28
Activity - 10
Problem Statement: Lottery Contract
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Lottery
{ address public
manager;
address[] public players;
event LotteryStarted();
event WinnerSelected(address winner);
constructor()
{ manager =
msg.sender;
}
29
// Transfer the entire contract balance to the winner
payable(winner).transfer(address(this).balance);
Output:
30
Activity - 11
Problem Statement: Supply Chain Contract
Build a supply chain contract that tracks the movement of goods from
producer to consumer.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
31
contract
SimpleSupplyChain
{ address public
producer; address
public consumer;
bool public delivered;
event ProductProduced();
event ProductShipped();
event ProductDelivered();
constructor()
{ producer =
msg.sender;
delivered = false;
}
Output:
32
Activity - 12
Problem Statement: KYC Contract
Build a contract that verifies user identity using KYC (Know Your
Customer) principles.
Pre-Requisites:
33
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
struct KYCData
{ KYCStatus status;
string data; // In a real KYC system, this would be more detailed user data
}
constructor()
{ owner =
msg.sender;
}
34
pending"); kycRecords[_user].status = KYCStatus.Rejected; emit
KYCRejected(_user);
}
}
Output:
Activity - 13
Problem Statement: Subscription Contract
35
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
constructor(uint256 _subscriptionPrice)
{ owner = msg.sender;
subscriptionPrice = _subscriptionPrice;
nextPaymentDue = block.timestamp + 30 days; // Initial subscription is for 30
days
}
Output:
Activity - 14
Problem Statement: Stake Contract
Design a contract that allows users to stake tokens in return for rewards.
Pre-Requisites:
37
1. Remix Engine
2. Solidity Compiler
Program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleStaking
{ address public
owner; uint256 public
rewardRate; uint256
public totalStaked;
constructor(uint256 _rewardRate)
{ owner = msg.sender;
rewardRate = _rewardRate;
}
38
uint256 reward = (stakedBalances[msg.sender] *
rewardRate) / 100; require(reward > 0, "No rewards to
claim"); rewards[msg.sender] += reward;
emit RewardClaimed(msg.sender, reward);
}
Activity - 15
Problem Statement: Pet Shop Contract
Design a contract that allows users to purchase pets from the shop.
39
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract Adoption
{ address[16] public
adopters;
Output:
40
41