Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Waas gorgos

View GitHub Profile
View FutureBlockHash.example.sol
mapping (address => uint256) gameWeiValues;
mapping (address => uint256) blockHashesToBeUsed;
function playGame() public {
if (!blockHashesToBeUsed[msg.sender]) {
// first run, determine block hash to be used
blockHashesToBeUsed[msg.sender] = block.number + 2; // use 2 or more
gameWeiValues[msg.sender] = msg.value;
return;
}
View ExtCodeHashExample.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.10;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
interface ExternalContractInterface {
function game() external returns(ExtCodeHashExample);
function payoutToWinner(address winner) external;
function withdrawTo(uint roundId, address receiver) external;
receive() external payable;
@gorgos
gorgos / BalancerExample.sol
Last active Dec 16, 2020
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.7.2+commit.51b20bc0.js&optimize=true&gist=
View BalancerExample.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.2;
interface PoolInterface {
function swapExactAmountIn(address, uint, address, uint, uint) external returns (uint, uint);
function swapExactAmountOut(address, uint, address, uint, uint) external returns (uint, uint);
}
interface TokenInterface {
function balanceOf(address) external returns (uint);
@gorgos
gorgos / TokenSwapWith0x.sol
Last active Jan 21, 2021
0x API Integration Example
View TokenSwapWith0x.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;
interface IERC20 {
function balanceOf(address owner) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transfer(address to, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
@gorgos
gorgos / ExampleSlidingWindowOracleDaiWethKovan.sol
Created Jan 9, 2021
ExampleSlidingWindowOracle with DAI + WETH for Kovan.
View ExampleSlidingWindowOracleDaiWethKovan.sol
pragma solidity 0.6.6;
pragma experimental ABIEncoderV2;
import "https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/interfaces/IUniswapV2Pair.sol";
import "https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/FixedPoint.sol";
import "https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/FullMath.sol";
import "https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/Babylonian.sol";
import "https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/BitMath.sol";
library SafeMath {
@gorgos
gorgos / High-Stakes Roulette Example
Last active Feb 20, 2021
Example for a contract for playing high-stakes Roulette on the blockchain
View High-Stakes Roulette Example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract BankOwned {
address public bankAddress;
constructor() {
bankAddress = msg.sender;
}