Sam 4
Sam 4
Roll no – 60
PRN no - 2043110151
Branch - CSE
Subject - Block Chain and Digital Currency
Experiment - 4
Theory -
- Solidity - Struct
Structs in Solidity allow you to create more complicated data types
that have multiple
Syntax:
struct <structure_name> {
<data type> variable_1;
; }
- Solidity - Arrays
In Solidity, an array can be of compile-time fixed size or of dynamic
size. For storage
the first element and the highest address to the last element.
Declaring Arrays
uint balance[10];
You can initialize Solidity array elements either one by one or using
a single
statement as follows
The number of values between braces [ ] can not be larger than the
number of
If you omit the size of the array, an array just big enough to hold the
initialization is
You will create exactly the same array as you did in the previous
example.
balance[2] = 5;
The above statement assigns element number 3rd in the array a
value of 5.
uint size = 3;
of the element within square brackets after the name of the array.
For example
The above statement will take 3rd element from the array and assign
the value to
contract receives plain Ether without any data. To receive Ether and
add it to the total
• If it is not marked
payable
as gas. Gas also has a variable price measured in ether (ETH), the
network's native
token.
While the gas needed for a specific transaction can stay the same,
gas prices can rise
your transaction. However, you should also consider the gas limit,
which defines
In other words, the gas cost is the amount of work required, and the
gas price is the
price paid for “each hour” of work. The relation between these two
and the gas limit
.
Let's pick a random transaction on Etherscan.io as an example. The
transaction cost
21,000 gas, and the gas price was 71 Gwei. So, the total transaction
fee was
expectation that gas fees will decrease. The amount of gas needed to
confirm a
contract MarksManagmtSys
// student details
struct StudentStruct
uint ID;
string fName;
string lName;
uint marks;
address owner;
StudentStruct[] stdRecords;
constructor()
owner=msg.sender;
}
// Create a function to add
stdCount = stdCount + 1;
return stdRecords;
}
Output -
1) An analysis of the transaction fee and gas fee
required for contract deployment.
2) An analysis of the transaction fee and gas fee required for smart
contracts transactions.