Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am saurfang on github.
  • I am saurfang86 (https://keybase.io/saurfang86) on keybase.
  • I have a public key ASC6o2FrmLXuQC429VAJuUzvrfA1Gi_i4Me6h-MyiuYJqgo

To claim this, I am signing this object:

@saurfang
saurfang / count
Last active May 14, 2018 19:29
devtools::update_packages install packages multiple times
grep 'DONE ' update_packages.log | sort | uniq -c | sort -bgr
9 * DONE (rlang)
7 * DONE (withr)
3 * DONE (scales)
3 * DONE (pkgbuild)
2 * DONE (rcmdcheck)
2 * DONE (pkgload)
2 * DONE (ggplot2)
1 * DONE (tidyjson)
1 * DONE (plotly)
pragma solidity ^0.4.21;
contract Miner {
uint public blockNumber;
uint public blocks;
function Miner() public {
reset();
}
const PredictTheFutureChallenge = artifacts.require('PredictTheFutureChallenge');
const PredictTheFutureSolver = artifacts.require('PredictTheFutureSolver');
contract('PredictTheFutureSolver', ([account]) => {
it('should solve the challenge', async () => {
let challenge = await PredictTheFutureChallenge.new({value: web3.toWei(1, 'ether')});
let solver = await PredictTheFutureSolver.new();
let guess = 0;
await solver.lockInGuess(challenge.address, guess, {value: web3.toWei(1, 'ether')});
pragma solidity ^0.4.21;
import "./GuessTheNewNumberChallenge.sol";
contract GuessTheNewNumberSolver {
address owner;
function GuessTheNewNumberSolver() public {
owner = msg.sender;
}
const GuessTheNewNumberChallenge = artifacts.require('GuessTheNewNumberChallenge');
const GuessTheNewNumberSolver = artifacts.require('GuessTheNewNumberSolver');
contract('GuessTheNewNumberSolver', ([account]) => {
it('should solve the challenge', async () => {
let challenge = await GuessTheNewNumberChallenge.new({value: web3.toWei(1, 'ether')});
let solver = await GuessTheNewNumberSolver.new();
await solver.guess(challenge.address, {value: web3.toWei(1, 'ether')});
const GuessTheNewNumberChallenge = artifacts.require('GuessTheNewNumberChallenge');
const GuessTheNewNumberSolver = artifacts.require('GuessTheNewNumberSolver');
contract('GuessTheNewNumberSolver', ([account]) => {
it('should solve the challenge', async () => {
let challenge = await GuessTheNewNumberChallenge.new({value: web3.toWei(1, 'ether')});
let solver = await GuessTheNewNumberSolver.new();
assert(
await solver.isComplete(challenge.address) === true,
const GuessTheNewNumberChallenge = artifacts.require('GuessTheNewNumberChallenge');
contract('GuessTheNewNumberChallenge', ([account]) => {
it('should be completed', async () => {
let challenge = await GuessTheNewNumberChallenge.new({value: web3.toWei(1, 'ether')});
assert(
await challenge.isComplete() === true,
'Challenge has not been completed!'
);
// transaction hash of contract deploy
var txHash = '0x75acf5e313e2c06e84d9e2609297b6a6f959773e7a4380daa66cc39ba59d6104';
// get transaction
web3.eth.getTransaction('0x75acf5e313e2c06e84d9e2609297b6a6f959773e7a4380daa66cc39ba59d6104', (err, tx) => {
console.log(tx);
var blockNumber = tx.blockNumber;
web3.eth.getBlock(blockNumber, (err, block) => {
console.log(block);
// address of deployed contract
var contractAddress = '0xDd56dCD052548Ac005563f42d13B4D502deCd379';
// get storage at slot 0
var storageAt0;
web3.eth.getStorageAt(contractAddress, 0, (err, res) => {
// convert to uint
console.log(`0: uint8: ${web3.toDecimal(res)}`);
});