BlockChain Workshop_Section 2
BlockChain Workshop_Section 2
https://docs.microsoft.com/en-us/windows/application-
management/sideload-apps-in-windows-10
• Working on your own device
2) Truffle and Ganache
Solution…. to turn of sideloading in Group Policy
1
2
Solution…. to turn of sideloading in Group Policy
2) Truffle and Ganache
2) Ganache and Truffle
2) Ganache and Truffle
• In the cmd – keyin C:\Users\TAR UC>npm install -g truffle OR
• In the cmd – keyin C:\Users\TAR UC>npm install truffle -g OR
• In the cmd – keyin C:\Users\TAR UC>npm i truffle -g
Verify the truffle installation in Powershell / cmd
prompt using this command truffle version
2) Ganache and Truffle
• In the cmd – keyin C:\Users\TAR UC>npm install -g ganache-cli
3) Ethereum wallet
https://ethereum.org/
FaucETH
• https://fauceth.komputing.org/X
https://sepoliafaucet.com/ 28.11.2023
https://www.infura.io/faucet/sepolia 28.11.2023
https://beyondfaucet.com/sepolia/
- change Account Name
- View your account transaction on Etherscan website
- Export Private Key (remember hide it, don’t let other to see your
private key)
Address of my BMIS2003BAD-chawtv-1
Send the ether from one account to another
account
Constructor() https://docs.soliditylang.org/en/v0.8.19/
get ( ): string
SPDX License Identifier
• https://docs.soliditylang.org/en/v0.6.8/layout-of-source-files.html
// SPDX-License-Identifier: MIT
When to use Storage Vs Memory in Solidity
• You must having knowledge of how your variables and data (storage
layout) are handled by the EVM
• in pragma solidity ^0.5.0 and above
• Memory- temporary place to store data. Smart Contract can use any
amount of memory during the execution but once the execution
stops, the Memory is completely wiped off for the next execution.
• Storage - holds data between function calls. Storage is persistent,
each execution of the Smart contract has access to the data
previously stored on the storage area.
When to use Storage Vs Memory in Solidity
• State variables and Local Variables of structs, array are always stored
in storage by default.
• Function arguments are in memory.
• Whenever a new instance of an array is created using the keyword
‘memory’, a new copy of that variable is created. Changing the array
value of the new instance does not affect the original array.
When to use Calldata in Solidity
• in pragma solidity v0.6.9 and above
• Calldata is only valid for parameters of external contract functions and
is required for this type of parameter. Calldata is a non-modifiable,
non-persistent area where function arguments are stored, and
behaves mostly like memory.
• It is recommended to try to use calldata because it avoids
unnecessary copies and ensures that the data is unaltered.
• For array parameters in functions, it is recommended to
use calldata over memory , as this provides significant gas savings.
1. Declare state variable with public (visibility specifier), then can
remove get() function
string public yourName;
Exercise 2: 2. Set the default value when declare the state variable in the
MODIFY smart contract. Then can remove the default value in the
constructor function
Greeter.sol (in string public yourName = "Hello World 123";
Exercise 1)
3. Declare state variable as constant which don’t want the user
to change this value. Then can remove set() function
string public constant value = "myValue2";
Compared to regular state variables, the gas costs of constant and immutable variables are much lower
• Design of the SimpleStorage.sol
Exercise 3:
SimpleStorage.sol
copy the Smart Contract address and put it in the local contract address. Then at that address, you are creating one
more smart contract. That's how the smart contracts all over the world are in consistent state.
Send the ether from one account to another
account