Skip to content

Instantly share code, notes, and snippets.

@nanomobile
nanomobile / repo-rinse.sh
Created June 24, 2018 08:09 — forked from nicktoumpelis/repo-rinse.sh
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@nanomobile
nanomobile / ECDSA-secp256k1-example.cs
Created June 1, 2018 20:15 — forked from nakov/ECDSA-secp256k1-example.cs
ECDSA with secp256k1 in C# - Generate Keys, Sign, Verify
using System;
using System.Text;
using Nethereum.Hex.HexConvertors.Extensions;
using Nethereum.Signer;
using Nethereum.Util;
using Nethereum.Signer.Crypto;
class ECDSASecp256k1Example
{
static void Main()
@nanomobile
nanomobile / README.md
Created April 26, 2018 14:23 — forked from MJeorrett/README.md
Private Ethereum network using Clique

DRAFT

Assume working directory of ~/playground/ethereum and that terminal windows are all opened here.

Create account

$ geth --datadir ./node1 account new

You will be prompted to enter and confirm a password. This will create a "keystore" directory in your working directory with the key for the created account saved in it.

pragma solidity ^0.4.18;
contract owned {
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
contract Random {
/* Generates a random number from 0 to 100 based on the last block hash */
function randomGen(uint seed) constant returns (uint randomNumber) {
return(uint(sha3(block.blockhash(block.number-1), seed ))%100);
}
/* generates a number from 0 to 2^n based on the last n blocks */
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
uint n = 0;
for (uint i = 0; i < size; i++){
pragma solidity ^0.4.16;
contract owned {
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
pragma solidity ^0.4.18;
contract SmartCasino {
uint public lucky;
function GetRoll(string clientSeed) payable public {
lucky = uint(keccak256(bytes32ToString(block.blockhash(block.number-1)), clientSeed)) % 10000;
}
function bytes32ToString(bytes32 x) private constant returns (string) {
@nanomobile
nanomobile / Random generator
Created April 13, 2018 06:50 — forked from alexvandesande/Random generator
A very simple random generator. A miner can influence the number by not publishing a block with an unwanted outcome, and forfeiting the 5 block reward.
contract random {
/* Generates a random number from 0 to 100 based on the last block hash */
function randomGen(uint seed) constant returns (uint randomNumber) {
return(uint(sha3(block.blockhash(block.number-1), seed ))%100);
}
/* generates a number from 0 to 2^n based on the last n blocks */
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
uint n = 0;
for (uint i = 0; i < size; i++){
// <ORACLIZE_API>
/*
Copyright (c) 2015-2016 Oraclize SRL
Copyright (c) 2016 Oraclize LTD
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 without limitation the rights
/*
* @title String & slice utility library for Solidity contracts.
* @author Nick Johnson <arachnid@notdot.net>
*
* @dev Functionality in this library is largely implemented using an
* abstraction called a 'slice'. A slice represents a part of a string -
* anything from the entire string to a single character, or even no
* characters at all (a 0-length slice). Since a slice only has to specify
* an offset and a length, copying and manipulating slices is a lot less
* expensive than copying and manipulating the strings they reference.