Skip to content

Instantly share code, notes, and snippets.

View rhlsthrm's full-sized avatar
🚀
Shipping

Rahul Sethuram rhlsthrm

🚀
Shipping
View GitHub Profile
pragma solidity ^0.6.0;
// Send an 0 value transaction with no data to mint 1,000 new tokens
//
// Symbol : DAI
// Name : Dai Stablecoin System
// Total supply: 1,000,000.000000000000000000 + faucet minting
// Decimals : 18
// Version : 1
// Chain ID : 4
@rhlsthrm
rhlsthrm / ReentrancyToken.sol
Created October 9, 2018 17:18
Fake ERC20 token that recreates reentrancy attack
pragma solidity ^0.4.23;
import "./HumanStandardToken.sol";
import "../../LedgerChannel.sol";
contract ReentrancyToken is HumanStandardToken {
LedgerChannel ledgerChannel;
uint256 constant MAX_REENTRIES = 5;
uint256 numReentries = 0;
@rhlsthrm
rhlsthrm / MockDai.sol
Created March 1, 2019 04:51
Mintable token using latest OpenZeppelin contracts, for Solidity ^0.5.2.
pragma solidity ^0.5.2;
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
*/
library Roles {
struct Role {
mapping (address => bool) bearer;
}
import { Sequelize } from "sequelize";
import { getPostgresStore } from "@connext/store";
import { connect as connext } from "@connext/client";
import {
ColorfulLogger,
getTestReceiptToSign,
getTestVerifyingContract,
signReceiptMessage,
} from "@connext/utils";
import {
@rhlsthrm
rhlsthrm / prysm-digitalocean-setup
Last active June 7, 2020 10:42
Instructions to install Prysm on Digital Ocean Ubuntu.
# VM Specs
- Ubuntu 4GB RAM
- 20GB HD
# Prerequisites
- Docker
```sh
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
-- GET NODE FREE BALANCE ACROSS ALL CHANNELS FOR TOKEN
SELECT ("latestState" #> '{balances}' -> (
SELECT array_position(
array(
SELECT jsonb_array_elements_text("latestState" #> '{tokenAddresses}')),
'0xEcFcaB0A285d3380E488A39B4BB21e777f8A4EaC' -- TOKEN ADDRESS
)::integer - 1
) #> '{0,amount,_hex}')
FROM channel INNER JOIN app_instance
ON app_instance."channelMultisigAddress" = channel."multisigAddress"
@rhlsthrm
rhlsthrm / SwiftCallbackHell.swift
Last active May 29, 2020 18:55
Swift code to use raw Grand Central Dispatch to make requests
import Foundation
var todos = [String: Any]()
let dispatchGroup = DispatchGroup()
for todo in 0..10 {
let url = URL(string: "https://jsonplaceholder.typicode.com/todos/\(todo)")
dispatchGroup.enter()
let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
import { ethers } from "@nomiclabs/buidler";
import { Signer, Wallet } from "ethers";
import chai from "chai";
import { deployContract, solidity } from "ethereum-waffle";
import CounterArtifact from "../artifacts/Counter.json";
import { Counter } from "../typechain/Counter";
chai.use(solidity);
const { expect } = chai;
@rhlsthrm
rhlsthrm / machine.js
Last active May 1, 2020 15:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rhlsthrm
rhlsthrm / admin.ts
Created April 15, 2020 16:12
Calculate pending balances
import { connect } from "ts-nats";
import { StateChannelJSON, toBN, CoinTransfer } from "@connext/types";
import { Zero, AddressZero } from "ethers/constants";
import { formatEther } from "ethers/utils";
type FreeBalanceAppState = {
activeApps: any[];
tokenAddresses: string[];
balances: CoinTransfer[][];
};