Skip to content

Instantly share code, notes, and snippets.

View ArslanKathia's full-sized avatar
🌏
Working from home

Arslan Maqbool ArslanKathia

🌏
Working from home
View GitHub Profile
@ArslanKathia
ArslanKathia / contracts...inheritance.sol
Created January 26, 2023 17:29
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract A{
uint private x= 100;
uint public y =200;
address private addr = msg.sender;
function fun1() public pure returns(string memory){
@ArslanKathia
ArslanKathia / contracts...events.sol
Created January 26, 2023 17:43
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract Events{
//event is used to set the values on blockchain.
event balance(address account,string message,uint val);
//this function transaction function or simple function because its have no return did change any state variable
@ArslanKathia
ArslanKathia / contracts...multipleInheritance.sol
Created January 28, 2023 19:36
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
// in multiple inhertiance
// Most Based Like to Most Derived
//Right to left - Depth First Manner
contract A{
uint public a;
constructor(){
@ArslanKathia
ArslanKathia / contracts...overridefunctionInMultipleInheritance.sol
Created January 29, 2023 17:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract A{
uint public a;
constructor(){
a = 100;
}
function funA() public{
@ArslanKathia
ArslanKathia / contracts...passingParameterInMH.sol
Created January 29, 2023 17:10
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract A{
string public name;
uint public age;
constructor(string memory _name,uint _age){
name = _name;
age = _age;
@ArslanKathia
ArslanKathia / contracts...callingParentFunction.sol
Created January 29, 2023 17:40
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract A{
event log(string text,uint age);
function fun1() public virtual{
emit log("A.fun1",21);
}
function fun2() public virtual{
@ArslanKathia
ArslanKathia / contracts...requirefunctionality.sol
Created January 30, 2023 12:07
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract Require{
address public owner = msg.sender;
uint public age = 25;
//when require condition is false than execution stopped and previously set the state variable goes to reset state
// and refund the gas fee.
function CheckAge(uint _x) public{
@ArslanKathia
ArslanKathia / contracts...revertAssert.sol
Created January 30, 2023 16:31
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract RevertAssert{
address public owner = msg.sender;
uint public age = 25;
function CheckAge(uint _x) public{
age = age + 5;
@ArslanKathia
ArslanKathia / contracts...modifier.sol
Created January 30, 2023 17:25
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract modifiers{
address public owner = msg.sender;
uint public _xx = 10;
//modifier is used to reuse the same code from the starting or ending of the function
@ArslanKathia
ArslanKathia / contracts...payable.sol
Created January 31, 2023 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract Payable{
// address make it payable
address payable public owner = payable(msg.sender);