Skip to content

Instantly share code, notes, and snippets.

View d1ll0n's full-sized avatar

Dillon Kellar d1ll0n

View GitHub Profile

0x2bf16b1275aab773bf22f1a5d03d56fa75e76ea713e8267cb2b1ed994d89793c

In buidler.config.js add this:

usePlugin("@nomiclabs/buidler-web3");

You can do this with ethers but I am more familiar with web3, so that's what this example uses.

Also do:

pragma solidity ^0.6.0;
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
pragma solidity ^0.6.0;
contract Log2 {
/**
* @dev Computes the log2 of a uint64
* @author Formula taken from a stackoverflow post by Desmond Hume
* https://stackoverflow.com/a/11398748
*/
function log2(uint64 input) external view returns (byte) {
pragma solidity ^0.5.0;
contract MultiHashSha256 {
// https://github.com/pouladzade/Seriality/blob/master/src/BytesToTypes.sol
function bytesToBytes32(uint _offst, bytes memory _input, bytes32 _output)
internal pure {
assembly {
mstore(_output, add(_input, _offst))
mstore(add(_output, 32), add(add(_input, _offst), 32))
}
pragma solidity ^0.5.7;
contract OrderMaker5000 {
struct Order {
address from;
uint haveAmt;
uint haveTokenIdx;
uint wantAmt;
uint wantTokenIdx;
}
@d1ll0n
d1ll0n / BNS.sol
Created March 13, 2019 04:01
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.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity ^0.4.25;
pragma experimental ABIEncoderV2;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
@d1ll0n
d1ll0n / BNS.sol
Created March 13, 2019 01:12
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.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity ^0.4.25;
pragma experimental ABIEncoderV2;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
@d1ll0n
d1ll0n / BNS.sol
Created March 10, 2019 11:44
Better name service
pragma solidity ^0.5.5;
import "./strings.sol";
contract BetterNameService {
using strings for string;
struct TLDPrice {
uint price;
uint lastUpdate;