Final SoC Ethereum Report
Final SoC Ethereum Report
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract HelloWorld {
string public greeting = "Hello, World!";
Output:
fi
Activity - 2
Problem Statement: Token Creation
Develop a basic ERC-20 token smart contract, including functions for transfer,
balance, and approval.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract SimpleToken {
string public name = "Simple Token";
string public symbol = "ST";
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
constructor(uint256 initialSupply) {
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
Design a simple ICO (Initial Coin O ering) contract that allows users to buy tokens
and the owner to withdraw funds.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract SimpleICO {
address public owner;
uint256 public tokenPrice;
uint256 public totalTokens;
uint256 public tokensSold;
mapping(address => uint256) public balances;
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:
contract SimpleVoting {
mapping(address => bool) public hasVoted;
mapping(string => uint256) public proposalVotes;
string[] public proposals;
event Voted(address indexed voter, string proposal);
Create an escrow smart contract that holds funds until prede ned conditions are met.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract SimpleEscrow {
address public payer;
address public payee;
uint256 public amount;
bool public released;
constructor(address _payee) {
payer = msg.sender;
payee = _payee;
}
released = true;
(bool success, ) = payable(payee).call{value: amount}("");
require(success, "Transfer failed");
emit FundsReleased(payee, amount);
}
}
fi
fi
Output:
Activity - 6
Problem Statement: Wallet Contract
Construct a wallet contract that allows funds to be locked until a speci ed time.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract TimelockWallet {
address public owner;
uint256 public releaseTime;
uint256 public balance;
constructor(uint256 _releaseTime) {
owner = msg.sender;
releaseTime = _releaseTime;
}
modi er onlyOwner() {
require(msg.sender == owner, "Only the owner can perform this action");
_;
}
Output:
Activity - 7
Problem Statement: Multi Signature Wallet
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract MultiSigWallet {
address public owner;
address public signer1;
address public signer2;
address public signer3;
to.transfer(value);
emit Transfer(to, value);
}
}
fi
ffi
Output:
Activity - 8
Problem Statement: Decentralised Exchange
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract SimpleDecentralizedExchange {
address public owner;
uint256 public tokenBalance;
constructor() {
owner = msg.sender;
}
modi er onlyOwner() {
require(msg.sender == owner, "Only the owner can perform this action");
_;
}
tokenBalance += tokenAmount;
emit TokensPurchased(msg.sender, ethValue, tokenAmount);
}
tokenBalance -= _tokenAmount;
payable(msg.sender).transfer(ethValue);
fi
fi
fi
ffi
fi
fi
emit TokensSold(msg.sender, ethValue, _tokenAmount);
}
Output:
ffi
Activity - 9
Problem Statement: NFT Contract
Create a basic NFT contract, allowing the minting and transferring of unique
tokens.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract BasicNFT {
string public name;
string public symbol;
struct Token {
address owner;
string tokenURI;
}
Develop a lottery contract with an entry fee and randomised winner selection.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract Lottery {
address public manager;
address[] public players;
event LotteryStarted();
event WinnerSelected(address winner);
constructor() {
manager = msg.sender;
}
Output:
fi
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:
contract SimpleSupplyChain {
address public producer;
address public consumer;
bool public delivered;
event ProductProduced();
event ProductShipped();
event ProductDelivered();
constructor() {
producer = msg.sender;
delivered = false;
}
modi er onlyProducer() {
require(msg.sender == producer, "Only the producer can perform this action");
_;
}
modi er onlyConsumer() {
require(msg.sender == consumer, "Only the consumer can perform this action");
_;
}
Output:
fi
Activity - 12
Problem Statement: KYC Contract
Build a contract that veri es user identity using KYC (Know Your Customer)
principles.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract KYC {
address public owner;
struct KYCData {
KYCStatus status;
string data; // In a real KYC system, this would be more detailed user data
}
constructor() {
owner = msg.sender;
}
modi er onlyOwner() {
require(msg.sender == owner, "Only the owner can perform this action");
_;
}
Output:
Activity - 13
Problem Statement: Subscription Contract
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract SubscriptionService {
address public owner;
uint256 public subscriptionPrice;
uint256 public nextPaymentDue;
constructor(uint256 _subscriptionPrice) {
owner = msg.sender;
subscriptionPrice = _subscriptionPrice;
nextPaymentDue = block.timestamp + 30 days; // Initial subscription is for 30 days
}
modi er onlyOwner() {
require(msg.sender == owner, "Only the owner can perform this action");
_;
}
modi er subscriptionDue() {
require(block.timestamp >= nextPaymentDue, "Subscription payment is due");
_;
}
Output:
Activity - 14
Problem Statement: Stake Contract
Design a contract that allows users to stake tokens in return for rewards.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract SimpleStaking {
address public owner;
uint256 public rewardRate;
uint256 public totalStaked;
constructor(uint256 _rewardRate) {
owner = msg.sender;
rewardRate = _rewardRate;
}
modi er onlyOwner() {
require(msg.sender == owner, "Only the owner can perform this action");
_;
}
Output:
Activity - 15
Problem Statement: Pet Shop Contract
Design a contract that allows users to purchase pets from the shop.
Pre-Requisites:
1. Remix Engine
2. Solidity Compiler
Program:
contract Adoption {
address[16] public adopters;
Output: