Skip to content

Instantly share code, notes, and snippets.

View kvhnuke's full-sized avatar
🤗
1100011

Kosala Hemachandra kvhnuke

🤗
1100011
View GitHub Profile
contract Faucet {
address owner;
uint256 sendAmount;
mapping (address => uint) lastSent;
uint blockLimit;
function Faucet(){
owner = msg.sender;
sendAmount = 1000000000000000000;
blockLimit = 5;
}
@kvhnuke
kvhnuke / gist:4ef6d2412c949ea1ccab
Last active August 29, 2015 14:22
huge Storage ethereum contract
contract hugeStorage {
address owner;
uint counter;
uint maxLoop = 10;
mapping(uint => bytes32) storage;
mapping(uint => bytes) dataStorage;
event Logger(uint cntr, uint cntr2, bytes32 data, uint gas);
function hugeStorage(){
owner = msg.sender;
counter = 0;
var Web3 = require('web3');
var BigNumber = require('bignumber.js');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://:8545'));
//console.log(web3.eth.getBlock('0xea1d5ef2791197b10d05ee07ea16226a8f14251c9cc5e3ee8d348be4e114f561'));
var LATEST_BLOCK = web3.eth.getBlock('latest').number;
var STARTING_BLOCK = 2751491;//LATEST_BLOCK - 6008; //60*24*(60/14.38)=6008 (1 day)
console.log("LATEST BLOCK", LATEST_BLOCK);
console.log("STARTING BLOCK", STARTING_BLOCK);
@kvhnuke
kvhnuke / autoStart.sh
Created March 8, 2017 10:51
autostart parity geth when down
#!/bin/bash
while true
do
if [ ! `pgrep geth` ] ; then #change this to either pgrep geth or pgrep parity
#su ubuntu -c "/usr/bin/screen -m -d -S parity /usr/bin/parity --tracing on --relay-set strict --force-sealing --rpccorsdomain '*' --rpcaddr '0.0.0.0' --jsonrpc-hosts 'all' --warp --chain ~/ropsten-revert.json > /home/ubuntu/parity.log"
su ubuntu -c "/usr/bin/screen -m -d -S geth /home/ubuntu/geth-linux-amd64-1.5.9-a07539fb/geth --testnet --fast --cache=512 --rpc --rpcaddr '0.0.0.0' --rpccorsdomain '*'"
fi
sleep 10
done
@kvhnuke
kvhnuke / ENS.txt
Created March 10, 2017 11:47
ENS Using mew contracts
I'll show you how to start an ens auction using mew contract interface
make sure you are on ropston node
_hash is the sha3("myDomain"), oh and make sure the function is startAuction ***not Auctions :)
now wait for it to get mined, our domain name is mewtest.eth as you saw the sha3 hash is on just the mewtest sha3("mewtest")
now lets see the status of the auction
as you see status is 1, which means it is open for bidding, and deed 0x00... means no one bid on it yet
lets bid
in order to bid, you have to sha3 hash (domainNameHash,ownerAddress,Value,secretHash), lets see how to do this
select shaBid function from the contract hash is the hash of the domainName, and lets make the mew donation address the owner
value is in wei so make sure you convert your ether value to wei, im bidding 1 ether
0xA7DeFf12461661212734dB35AdE9aE7d987D648c
/**
* SimpleRegistrar lets you claim a subdomain name for yourself and configure it
* all in one step. This one is deployed at xxx.xxx.xxx.
*
* To use it, simply call register() with the name you want and the appropriate
* fee.
* SimpleRegistrar will take care of everything: registering your subdomain,
* setting up a resolver, and pointing that resolver at the account that called
* it.
*
@kvhnuke
kvhnuke / privkeys.txt
Created July 11, 2017 05:24
10000 private keys
0x60b98a7ea5ee79773a10b129a7608ee6db94a5859b421cbc14af6384cb00e9ab
0x1cc76bfd1a398b449a9747b384c91a94ce2e0367ef5a3b68353de18ea9308a03
0x8331f0e81f21947c516d07d520392cbc3ee891c47fad573904ea2902fe0ecd1b
0x60aa0418a36d559e5903fde21d63b50350c43dc9293ea17551a3a62fd09cd2c4
0x959fb22d569690eeefd609b13dea820bd09c027204da41870bdf5274eb16c23a
0xee36c5c4fad94144103a453a13a4ccaa91dbaa796c5f72b4960c6fca43e653d8
0xc71f720d0f56ee60f08b7b86354f7665ea062355304b9610282030ecf766ffa9
0x5aae22750dbf28402d1aad60bb11bffcac2d1fb0cb604d8789c8fd7216af42ee
0x7c150cc2f655e23bbe54ee82c3e3da993f9be8b32e49bbfd667200cd8662b93e
0xf7febf88c12898fe1eabe4ef702657539c53602c9d2f04766cb4a9d7b2839f00
var crypto = require("crypto");
var eccrypto = require("eccrypto");
var privKeyA = '8331f0e81f21947c516d07d520392cbc3ee891c47fad573904ea2902fe0ecd1b';
var privKeyB = '5aae22750dbf28402d1aad60bb11bffcac2d1fb0cb604d8789c8fd7216af42ee';
var privateKeyA = new Buffer(privKeyA, 'hex');
var publicKeyA = eccrypto.getPublic(privateKeyA);
var privateKeyB = new Buffer(privKeyB, 'hex');
var publicKeyB = eccrypto.getPublic(privateKeyB);
func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) {
tx, blockHash, blockNumber, index := core.GetTransaction(s.b.ChainDb(), hash)
if tx == nil {
return nil, nil
}
receipt, _, _, _ := core.GetReceipt(s.b.ChainDb(), hash) // Old receipts don't have the lookup data available
var signer types.Signer = types.FrontierSigner{}
if tx.Protected() {
signer = types.NewEIP155Signer(tx.ChainId())