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-live...whitelist-address-contract.sol
Created February 6, 2023 16:41
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: GPL-3.0
pragma solidity ^0.8.0;
/*
Declare a state variable for setting the maximum number of whitelisted addresses to be allowed.
Use mapping for maintaining a list of addresses and if they are whitelisted or not.
Initialize a maximum number of whitelisting addresses allowed using a constructor.
Write a function to add the address to the whitelist.
Write a function to check if the address is whitelisted or not.
*/
@ArslanKathia
ArslanKathia / contracts-live...todo-contract.sol
Created February 6, 2023 16:17
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: GPL-3.0
pragma solidity >= 0.7.0 < 0.8.18;
/*Set the owner to the deployer of the contract using the constructor.
Use mapping to keep track of each Task.
Write the modifier onlyOwner() so that only the owner can call certain functions.
Adding a new task to the list.
Fetching (Reading) the task from the list.
Mark the task as completed.*/
@ArslanKathia
ArslanKathia / contracts-live...lottery-contract.sol
Created February 5, 2023 16:48
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: GPL-3.0
pragma solidity >= 0.7.0 < 0.8.18;
contract Lottery{
address public manager;
address payable[] public players;
constructor(){
@ArslanKathia
ArslanKathia / contracts...in-built-cryptohashes.sol
Created February 4, 2023 20:11
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;
//solidity cryptographics builtin hash functions
contract HashFun{
//builtin functions
//keccak256
//hash256
//ripemd160
@ArslanKathia
ArslanKathia / contracts...data-location.sol
Created February 4, 2023 13:11
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 DataLocation{
uint[] public arr = [1,4,5,7,9,10,15];
//by default state variable store in storage
function Storage() public {
uint[] storage arrs = arr;
@ArslanKathia
ArslanKathia / contracts...immutable.sol
Created February 3, 2023 10:12
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 Immutable{
//immutable state variable can be set inline - constructor
address public immutable owner;
//constant defined only inline
@ArslanKathia
ArslanKathia / contracts...send_ether.sol
Created February 1, 2023 19:38
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 SentEther{
//address payable public getter = payable(0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2);
//add the ether in the smart contract using transact
receive() external payable{}
@ArslanKathia
ArslanKathia / contracts...fallback_receive.sol
Created January 31, 2023 18:37
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 fallback_receive{
event logs(string _msg,address _sender,uint _val,bytes _data);
//fallback is used to received the data but if received isn't present in contract
// than fallback handle the received functionality
@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);
@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