Skip to content

Instantly share code, notes, and snippets.

import { Body, Controller, Get, Post } from '@nestjs/common';
import base64url from 'base64url';
import {
arrayify,
hashMessage,
keccak256,
recoverAddress,
verifyMessage,
} from 'ethers/lib/utils';
import { connect, JSONCodec } from 'nats';

Keybase proof

I hereby claim:

  • I am kosecki123 on github.
  • I am piotrkosinski (https://keybase.io/piotrkosinski) on keybase.
  • I have a public key ASDEV0hBS6eUZ_qWJvbYdGpTyrj5OD3YHuMGSzWiwcdJ5Ao

To claim this, I am signing this object:

@kosecki123
kosecki123 / onchain_claiming_mechanism.R
Created June 18, 2018 06:11
onchain_claiming_mechanism.R using USD for target payout
set.seed(123)
tx_cost <- function(A_x, n, C_tx) {
(1 - A_x) * (n - 1) * C_tx
}
bounty <- function(timebounty, C_c, n) {
(timebounty - C_c) / n
}
@kosecki123
kosecki123 / onchain_claiming_mechanism.R
Created May 24, 2018 06:29
Simulation code for TimeNode expected payout
set.seed(123)
tx_cost <- function(A_x, n, C_tx) {
(1 - A_x) * (n - 1) * C_tx
}
bounty <- function(timebounty, C_c, n) {
(timebounty - C_c) / n
}
contract Test1 {
function add(int a, int b) returns(bytes){ //Simply add the two arguments and return
return abi.encode(a+b);
}
}
contract Test2 {
Test1 test1;
function Test2(){
function canExecute(bytes _serializedTransaction) public view returns(bool) {
address conditionalDest;
assembly {
conditionalDest := mload(add(_serializedTransaction, 320))
}
if (conditionalDest == 0x0) { //no conditional address set = no need to check
return true;
}
@kosecki123
kosecki123 / canExecute.sol
Last active May 7, 2018 00:14
canExecute
function execute(bytes _serializedTransaction)
public returns (bool)
{
require(checkHash(_serializedTransaction));
require(canExecute(_serializedTransaction));
...
}
@kosecki123
kosecki123 / callData.sol
Last active May 7, 2018 00:01
callData.sol
function callWithData(address dest, bytes data)
private returns (bytes32 c)
{
assembly {
let freemem := mload(0x40)
pop(
call(
5000,
dest,
pragma solidity ^0.4.21; // solhint-disable-line compiler-fixed
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
0x00F11A54f4436777DD16a52d49b28ba7D401F1cd