- Optional/nullable data types.
- Variant data types.
- Flag with extra information needed only in some cases (or different in different cases).
- Modeling states in a state machine where each state can have some data associated with it.
- List of operations for batch processing, where each operation can have its own arguments.
- Alternative to function overloading that allows avoiding combinatorial explosion when there are multiple parameters that need variants.
- Nested data structures with heterogenous nodes.
This file contains hidden or 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 | |
// https://community.optimism.io/docs/developers/bedrock/differences/#l1-contracts | |
pragma solidity 0.8.10; | |
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | |
/** | |
* @title L2OutputOracle | |
* @notice The L2 state is committed to in this contract | |
* The payable keyword is used on appendL2Output to save gas on the msg.value check. |
This file contains hidden or 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.11; | |
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; | |
contract Ownable_Page_Lottery is VRFConsumerBase { | |
address public owner; | |
address payable[] public players; | |
uint public lotteryId; |
This file contains hidden or 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
// To enable meta transaction, let create a generic method that calls executeMetaTransaction by taking the user signature | |
// and then execute transaction via Biconomy | |
// Dependencies | |
import {toBuffer} from "ethereumjs-util"; | |
import abi from "ethereumjs-abi"; | |
import events from "events"; | |
// Initialization of web3 | |
let web3 = new Web3(window.ethereum); |
This file contains hidden or 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
pragma solidity 0.6.12; | |
import '@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol'; | |
import '@pancakeswap/pancake-swap-lib/contracts/token/BEP20/IBEP20.sol'; | |
import '@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol'; | |
import '@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol'; | |
// import "@nomiclabs/buidler/console.sol"; | |
interface IWBNB { |