Skip to content

Instantly share code, notes, and snippets.

@what-the-func
what-the-func / ConnectFour.sol
Created November 27, 2022 17:37
Four in a row implemented in Solidity
// SPDX-License-Identifier: MIT
//
// Let's play connect-four!
// Check out the contract for details.
pragma solidity 0.8.17;
contract ConnectFour {
mapping(bytes32 => Game) public games; // Game IDs ==> Games
mapping(address => uint256) public nrOfGames; // User ==> Nr. of Games
@what-the-func
what-the-func / GasSaver.sol
Created September 4, 2020 06:51
CHI Token Gas Rebate Contract
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.7.0;
interface IFreeFromUpTo {
function freeFromUpTo(address from, uint256 value) external returns (uint256 freed);
}
contract GasSaver {
IFreeFromUpTo chi;
@what-the-func
what-the-func / Aggregator.sol
Created May 19, 2020 07:04
Chainlink Aggregator
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/dev/AggregatorInterface.sol";
contract MyContract {
AggregatorInterface internal feed;
constructor(address _aggregator) public {
feed = AggregatorInterface(_aggregator);
}
@what-the-func
what-the-func / Escrow.sol
Created March 12, 2020 05:47
Escrow Smart Contract
pragma solidity ^0.6.0;
contract Escrow {
enum State { AWAITING_PAYMENT, AWAITING_DELIVERY, COMPLETE }
State public currState;
address public buyer;
address payable public seller;
pragma solidity ^0.5.0;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../../flashloan/base/FlashLoanReceiverBase.sol";
import "../../configuration/LendingPoolAddressesProvider.sol";
import "../../lendingpool/LendingPool.sol";
contract FlashLoanReceiverExample is FlashLoanReceiverBase {