Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am linagee on github.
  • I am linagee (https://keybase.io/linagee) on keybase.
  • I have a public key whose fingerprint is C4CA C0B2 230D B30F 44CD C816 FAB6 9135 6B53 537F

To claim this, I am signing this object:

contract mortal {
/* Define variable owner of the type address*/
address owner;
/* this function is executed at initialization and sets the owner of the contract */
function mortal() { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) suicide(owner); }
}
> eth.getBlock(0)
{
difficulty: '17179869184',
extraData: '0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa',
gasLimit: 5000,
gasUsed: 0,
hash: '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3',
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
miner: '0x0000000000000000000000000000000000000000',
nonce: '0x0000000000000042',
@linagee
linagee / ethereum_test.js
Created August 21, 2015 21:53
Just realized I made the first executable code in Ethereum!
for (var x = 46400; x < 48650; x++) {
var transactions = eth.getBlock(x).transactions;
if (transactions.length > 0) {
for (var y = 0; y < transactions.length; y++) {
var transactionReceipt = eth.getTransactionReceipt(transactions[y]);
if (transactionReceipt.contractAddress !== null) {
console.log(transactionReceipt.contractAddress + " in TX: " + transactions[y] + " (block: " + x + ", timestamp: " + eth.getBlock(x).timestamp + ") contract: " + eth.getCode(transactionReceipt.contractAddress));
}
}
}
@linagee
linagee / contracts.js
Created August 21, 2015 19:48
Contract finder
//Look through the last 1000 blocks for contract addresses
var contractAddresses = [];
var blockNumber = eth.getBlock('latest').number;
console.log("Current block number: " + blockNumber);
for (var x = blockNumber; x > blockNumber - 1000; x--) {
var transactions = eth.getBlock(x).transactions;
var transactionsCount = transactions.length;
if (transactionsCount != 0) {
for (var y = 0; y < transactionsCount; y++) {
var transactionReceipt = eth.getTransactionReceipt(transactions[y]);
var weakHandsSource = 'contract weakHands { address owner; address triggerFriend; uint lockDate; function weakHands (address otherPerson) { owner = msg.sender; triggerFriend = otherPerson; lockDate = now + 5 days; } function requestEther(uint amount){ if (msg.sender==owner && now > lockDate) { owner.send(amount); } if (msg.sender==triggerFriend) { owner.send(amount); } } }';
var weakHandsCompiled = eth.compile.solidity(weakHandsSource);
var triggerFriend = '0x03c4c03f163d51105bbc0e1a63077cb04210aa83';
var weakHandsContract = web3.eth.contract(weakHandsCompiled.weakHands.info.abiDefinition);
var weakHands = weakHandsContract.new(
triggerFriend,
{
from:eth.accounts[2],
~/mist/mist$ electron ./
[9365:0810/082250:ERROR:browser_main_loop.cc(173)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
pci id for fd 16: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
[9397:0810/082252:INFO:renderer_main.cc(200)] Renderer process started
[9365:0810/082252:WARNING:accelerator_util.cc(185)] Invalid accelerator token: command
[9365:0810/082252:WARNING:accelerator_util.cc(185)] Invalid accelerator token: command
[9365:0810/082252:WARNING:accelerator_util.cc(185)] Invalid accelerator token: command
[9365:0810/082252:WARNING:accelerator_util.cc(185)] Invalid accelerator token: command
var helloEthereumContract = 'contract testContract { function go() constant returns (string) { return "Hello Ethereum!"; }}'
var helloEthereumCompiled = web3.eth.compile.solidity(helloEthereumContract)
var ethereumContract = web3.eth.contract(helloEthereumCompiled.testContract.info.abiDefinition);
var helloEthereum = ethereumContract.new({from:eth.coinbase, data: helloEthereumCompiled.testContract.code, gas: 199352}, function(e, contract){
console.log("CALLBACK!");
if(!e) {
if(!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
} else {
console.log("Contract mined! Address: " + contract.address);
var helloEthereum = 'contract testContract { function go() constant returns (string) { return "ETHEREUM!"; }}'
var helloEthereumCompiled = web3.eth.compile.solidity(helloEthereum)
var ethereumContract = web3.eth.contract(helloEthereumCompiled.testContract.info.abiDefinition);
var ethereum = ethereumContract.new(null, {from:eth.coinbase, data: helloEthereumCompiled.testContract.code, gas: 34000}, function(e, contract){
if(!e) {
if(!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");