This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Javascript module to construct and hash EIP-712 typed messages to be signed by private key. | |
* [EIP712]{@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md} standard | |
* | |
* @author Ashwin Yardi | |
* @module eip712Signature | |
*/ | |
const { padLeft, sha3 } = require("web3-utils"); | |
const web3EthAbi = require("web3-eth-abi"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solidity program to demonstrate | |
// value types | |
pragma solidity ^ 0.8.5; | |
// Creating a contract | |
contract DemoValueTypes { | |
// Initializing Bool variable | |
bool public boolean; | |
// Initializing Integer variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solidity program to demonstrate | |
// reference types | |
pragma solidity ^ 0.8.5; | |
// Creating a contract | |
contract DemoReferenceTypes { | |
// Defining an array of fixed size | |
uint[5] public fixedSizeArray = [uint(1), 2, 3, 4, 5]; | |
// Defining a Structure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solidity program to demonstrate | |
// how modifying storage items is expensive | |
pragma solidity ^ 0.8.5; | |
contract StorageVariableDemo | |
{ | |
uint public temp; | |
/* | |
* @description:Below function runs the for loop 100 times and updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ethers } from "hardhat"; | |
import keccak256 from "keccak256"; | |
import { MerkleTree } from "merkletreejs"; | |
import { merkleTreeLeaves, validAddress, invalidAddress } from "./utils/mock-data"; | |
import { MerkleVerifier } from "../typechain-types/MerkleVerifier"; | |
let merkleTree: MerkleTree; | |
let merkleVerifier: MerkleVerifier; | |
function generateMerkleTree() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; | |
contract MerkleVerifier { | |
bytes32 public merkleRoot; | |
constructor(bytes32 _merkleRoot) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.0; | |
contract Storage { | |
uint firstVar; | |
uint secondVar; | |
string thirdVar; | |
string fourthVar; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.0; | |
contract FacetA { | |
struct DiamondStorage { | |
uint firstVar; | |
uint secondVar; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.7; | |
contract DemoErrors { | |
function demoRequire(uint input) public pure { | |
require(input > 5, "input must be greater than 5"); | |
} | |
function demoRevert(uint input) public pure { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.7; | |
contract DemoCustomError { | |
error Unauthorized(); | |
error myCustomError(string message); | |
address public owner = address(0x0); |
OlderNewer