Skip to content

Instantly share code, notes, and snippets.

let Deposit = artifacts.require("./DepositContract")
let Flame = artifacts.require("./FlameToken")
let Master = artifacts.require("./MasterDeposit")
contract("DepositContract", function(accounts) {
let deposit
let master
let someone = accounts[0]
let token
let sender = accounts[1]
pragma experimental ABIEncoderV2;
pragma solidity ^0.4.24;
library merkleMap{
struct node{
bytes32 key;
bytes32 value;
bytes32 leftChildHash;
bytes32 rightChildHash;
pragma solidity 0.4.24;
contract stateChannel{
uint blockPeriod;
uint neededSignatures;
struct participant{
bool isNeeded;
uint256 block;
}
it('should set prices correctly for multiple buy sell orders for a single crypto', async function () {
let price = await this.investment.decodePrices.call([1, 1, 1],"{\"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87}}", true)
price[1].should.be.bignumber.equal(toEther(8180.87))
price[2].should.be.bignumber.equal(toEther(8180.87))
price[3].should.be.bignumber.equal(toEther(8180.87))
})
function claimOwnership(uint8 v, bytes32 r, bytes32 s) public returns (bool) {
require(validSignature(v, r, s));
invalidateSignature(v, r, s);
if (ecrecover(keccak256("emergency ownership transfer"), v, r, s) == owner) {
address oldOwner = owner;
owner = msg.sender;
emit EmergencyOwnershipTransfer(oldOwner, msg.sender);
return true;
}
return false;
function negModN(uint256 s) returns(bytes32){
return bytes32(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s);
} //0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 is the order of the Ethereum elliptic curve
auth:
type: "object"
required:
- "hash"
- "v"
- "r"
- "s"
properties:
hash:
type: "string"
@aleph-v
aleph-v / superAssembly.sol
Last active January 6, 2022 02:59
Super assembly optomized version of spec256r verification, takes sig verification from ~900K to ~300K gas
// Partially derived from code by Lionello Lunesu
pragma solidity ^0.5.2;
contract ModExp {
// address constant MODEXP_BUILTIN = 0x0000000000000000000000000000000000000005;
function modexp(uint256 b, uint256 e, uint256 m) internal returns(uint256 result) {
@aleph-v
aleph-v / ERC720_delegated.sol
Last active January 12, 2019 02:16
Delegated ERC721 with nonce
pragma solidity ^0.4.24;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../introspection/ERC165.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic implementation with added support for metatransactions
pragma solidity ^0.4.24;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../introspection/ERC165.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic implementation