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
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | |
import "./IVestingFactory.sol"; | |
contract VestingProxy is ERC1967Proxy { | |
/** | |
* @dev Storage slot with the factory of the contract. | |
* This is the keccak-256 hash of "co.example.factory" subtracted by 1, and is | |
* validated in the constructor. |
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
pragma solidity ^0.8.0; | |
library DateTime { | |
uint256 constant SECONDS_PER_DAY = 24 * 60 * 60; | |
int256 constant OFFSET19700101 = 2440588; | |
function _daysFromDate( | |
uint256 year, | |
uint256 month, | |
uint256 day |
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
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; | |
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | |
import "./DateTime.sol"; | |
/** |
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
pragma solidity ^0.8.10; | |
contract ReEntrancyGuard { | |
bool internal locked; | |
modifier noReentrant() { | |
require(!locked, "No re-entrancy"); | |
locked = true; | |
_; | |
locked = false; |
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
contract Multisend { | |
function multisendEther(address[] memory recipients, uint256[] memory values) | |
external | |
payable | |
{ | |
for (uint256 i = 0; i < recipients.length; i++) | |
payable(recipients[i]).transfer(values[i]); | |
uint256 balance = address(this).balance; | |
if (balance > 0) payable(msg.sender).transfer(balance); | |
} |
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
contract Staking { | |
function isContract(address _target) internal view returns (bool) { | |
if (_target == address(0)) { | |
return false; | |
} | |
uint256 size; | |
assembly { | |
size := extcodesize(_target) | |
} |
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
pragma solidity ^0.4.19; | |
contract MaximumMultiple { | |
function maxMultiple(int d, int b) public pure returns (int) { | |
// | |
int max = d > b ? d : b; | |
int min = d < b ? d : b; | |
return max - max % min; | |
} | |
} |
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
pragma solidity ^0.4.19; | |
contract Century { | |
function get(int year) public pure returns (int) { | |
return (year - 1) / 100 + 1; | |
} | |
} |
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
pragma solidity ^0.4.19; | |
contract Problem { | |
function rowSumOddNumbers(int n) public pure returns (int) { | |
int end = (1 + n ) * n - 1; | |
int start = end - 2 * (n - 1); | |
int sum = (start + end) * n / 2; | |
return sum; | |
} | |
} |
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
pragma solidity ^0.4.13; | |
contract Repeater { | |
function multiply(uint8 repeat, string pattern) returns (string) { | |
bytes memory bpattern = bytes(pattern); | |
uint resultLength = repeat * bpattern.length; | |
string memory result = new string(resultLength); | |
bytes memory bresult = bytes(result); | |
for (uint i = 0; i < resultLength; i++) { | |
bresult[i] = bpattern[i % bpattern.length]; |
NewerOlder