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.5.0; | |
contract HTLC { | |
address payable public sender; | |
address payable public receiver; | |
bytes32 public hashlock; | |
uint256 public timelock; | |
bytes32 public preimage; | |
constructor(address payable _receiver, bytes32 _hashlock, uint256 _timelock) public payable { |
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 "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol"; | |
contract TST is ERC20 { | |
constructor() ERC20("Test token", "TST") { | |
_mint(msg.sender, 10000 * (10**uint256(decimals()))); | |
} | |
} |
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 "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol"; | |
import "./Weth9.sol"; | |
interface Protocol { | |
function mint(uint256 amount) external; | |
function burn(uint256 amount) external; | |
function underlying() external view returns (IERC20); | |
function balanceUnderlying() external view returns (uint256); |
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: UNLICENSED | |
pragma solidity 0.8.7; | |
interface IERC20 { | |
function balanceOf(address account) external view returns(uint256); | |
} | |
interface IProxy { | |
function batchExec(address[] calldata tos, bytes32[] calldata configs, bytes[] memory datas) external payable; |
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: UNLICENSED | |
pragma solidity 0.8.14; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/proxy/beacon/BeaconProxy.sol"; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/proxy/beacon/UpgradeableBeacon.sol"; | |
import {ImplementationV1, ImplementationV2} from "./Implementation.sol"; | |
contract Setup { | |
address immutable public proxy1; | |
address immutable public proxy2; |
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
library LibFacet1 { | |
bytes32 constant storagePosition = keccak256("diamond.storage.LibFacet1"); | |
struct DiamondStorage { | |
uint256 n; | |
} | |
function diamondStorage() internal pure returns (DiamondStorage storage ds) { | |
bytes32 position = storagePosition; | |
assembly { |
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.7.0 <0.9.0; | |
contract Try { | |
function createBytes(uint256 n) public pure returns (bytes memory data) { | |
uint256[] memory ret = new uint256[](n); | |
for (uint256 i = 0; i < n; i++) { | |
ret[i] = i; | |
} |
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.15; | |
contract ContractFactory { | |
function deploy(uint256 n_, bytes calldata code_) external payable returns (address) { | |
Proxy p; | |
try new Proxy{salt: bytes32(n_)}() returns (Proxy _p) { | |
p = _p; | |
} catch { | |
revert("Deploy proxy failed"); |