0% found this document useful (0 votes)
121 views8 pages

Solidity Programs

The document contains 5 Solidity contract files with varying complexity - Mycontract1 defines a public string, Mycontract2 initializes the string, Mycontract3 adds a uint256, Mycontract4 uses a constructor to set values, and Mycontract5 uses a function to set the string and uint256. It also provides examples of experiments for learning Solidity basics like using Remix IDE, writing a counter contract, and exploring variable types and properties.

Uploaded by

Kumara S
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)
121 views8 pages

Solidity Programs

The document contains 5 Solidity contract files with varying complexity - Mycontract1 defines a public string, Mycontract2 initializes the string, Mycontract3 adds a uint256, Mycontract4 uses a constructor to set values, and Mycontract5 uses a function to set the string and uint256. It also provides examples of experiments for learning Solidity basics like using Remix IDE, writing a counter contract, and exploring variable types and properties.

Uploaded by

Kumara S
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/ 8

Mycontract1.

sol

pragma solidity ^0.8.13;

contract Mycontract1{

string public hey;

Mycontract2.sol

pragma solidity ^0.8.13;

contract Mycontract2 {

string public hey=”Hello Ethereum”;

Mycontract3.sol

pragma solidity ^0.8.13;

contract Mycontract3 {

string public hey=”Hello Ethereum”;

uint256 public no=4;

Mycontract4.sol

pragma solidity ^0.8.13;

contract Mycontract4 {

string public hey;

uint256 public no;


constructor (string memory _hey, uint256 _no)

hey=_hey;

no=_no;

Mycontract5.sol

pragma solidity ^0.8.13;

contract Mycontract5 {

string public hey;

uint256 public no;

function addInfo(string memory _hey,uint256 _no) public

hey=_hey;

no=_no;

}
List of Experiments:

Experiment 1 :
How to navigate to the Remix IDE web URL on the browser
and exploring the various tabs and features of the IDE.

How to open a Remix IDE

Step 1: Open any web browser


Step 2: Web browser type  https://remix.ethereum.org/
Step 3: To View Dashboard or Main screen in Remix IDE
We're using Remix IDE to Compile and Run our Solidity Code base.

Step 1 − Copy the given code in Remix IDE Code Section.


Step 2 − Under Compile Tab, click Start to Compile button.
Step 3 − Under Run Tab, click Deploy button.
Step 4 − Under Run Tab, Select SolidityTest at 0x... in drop-down.
Step 5 − Click getResult Button to display the result.
Remix IDE Workspace and features
Experiment 2 :
Dhanalakshmi is a student in Government Engineering College city school
in Mayiladuthurai, His teacher gave him homework to check whether a
number is Incrementing or Decrementing. Help her to solve the problem

NFT Counter Program

pragma solidity ^0.8.13;


contract NFTCount{
uint256 public numberofNFT;

//This function will increment the NFT Number


function addNFT() public
{
numberofNFT+=1;
}

//This function will delete the NFT by 1


function deleteNFT() public
{
numberofNFT-=1;
}
//check total number of NFT
function checkTotalNFT() public view returns(uint256)
{
return numberofNFT;
}
}
Experiment 3 :

Write a Program to understand the solidity variables and its properties.

pragma solidity ^0.8.13;


contract Datatypes{
//bool public hey;
bool public no=true;

/* uint8; //range 0-2 **8-1 //255


unit16; //ranges 0 -2 **16-1 // 65535
unit256; // ranges 0 - 2 ** 256-1 //1.1579209e+77
*/

uint public u8=1;


uint u256=456;
uint public u=123; // uint is an alias from uint256;

int8 public i8=-1;


int public i256=456;
int public i=-1234;

//Now you can add min and Max int

int public minInt=type(int).min;


int public maxInt=type(int).max;

bytes1 public a=0xb5;


bytes1 public b=0x56;
//address types
/*address public hey;
address public addr=
*/

//default values

bool public defaultBool; //false


uint public number; //0
int public defaultInt; // 0
address public hey; // 0x000000000
}

You might also like