Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Block-chain Technology

Assignment -1
Name- Shahbaz Khan
Roll No – 01UG19020042

Problem Statement 1:
Write a solidity contract program to show your name.

Solution Statement:
To store our name value we create a string variable named name in public
scope.

Program:
pragma solidity ^0.8.3;
contract Shahbaz {
string public name = "Shahbaz khan!";
}
Compile output:

Deploy Output:

Test Run Output:


Attached.

Problem Statement 2:
Writhe solidity contract program to show the following:
Title, First Name, Middle Name, Last Name.
Solution Statement:
We create a struct of candidate which will store their data accordingly.

Assignment Number: 04

 Problem Statement:
Write a Solidity contract program to add two numbers and display result:

 Program:
pragma solidity ^0.8.3;

contract addTwoNumber{

uint8 public iNum1=10;

uint8 public iNum2=125;

uint8 public result;

function getResult()public{

result = iNum1+iNum2;

 Output Compile:
 Output Deploy:

 Output Test Run:


Assignment Number: 05

 Problem Statement:
WASC for bank to deposit and withdraw.

 Program:
pragma solidity ^0.8.3;

contract Bank {

mapping(address => uint256) public balanceOf; // balances, indexed by addresses

function deposit(uint256 amount) public payable {


require(msg.value == amount);

balanceOf[msg.sender] += amount; // adjust the account's balance

function withdraw(uint256 amount) public payable{

require(amount <= balanceOf[msg.sender]);

balanceOf[msg.sender] -= amount;

payable(msg.sender).transfer(amount);

 Output Compile:

 Output Deploy:
 Output Test Run:

You might also like