2

The goal is to create a .csv file of all ethereum transactions essentially a large table with these columns

blocknumber, timestamp, fromaddress, toaddress, value

I wrote this script to run in the REPL for go-ethereum 1.5.0-unstable, installed from the ubuntu package manager after adding the ethereum and ethereum-dev ppas :

function csv(){
    var i,l,block,j,k,trans;
    var s;
    for(i=0,l=web3.eth.blockNumber;i<l;i++){
        block = web3.eth.getBlock(i, true);
        if (block && block.miner)
            console.log([i,block.timestamp,'M',block.miner,5].join(","));
        if (block && block.transactions){
            for(j=0,k=block.transactions.length;j<k;j++){
                trans = block.transactions[j];
                console.log([i,block.timestamp,trans.from,trans.to,
                             +web3.fromWei(trans.value,'ether')].join(","));
            }
        }
    }
};

csv();

It captures block mining reward, and manual transactions, but is missing automated contract transactions. I am aware that the script is also missing the genesis block settings, the 5/32 uncle rewards, and the gas payment to the miner, but what seems puzzling and a big source of inaccuracy at the moment are the missing automated "smart contract" transactions, which I was surprised do not appear in blocks along with ordinary transactions.

Example, for block 1965131 my script reports:

1965131,1469670959,M,0x2a65aca4d5fc5b5c859090a6c34d164135398226,5.0
1965131,1469670959,0xd6c9710363cdb12eb585e817f431d44cfa442dde,0xaa1a6e3e6ef20068f7f8d8c835d2d22fd5116444,31.0
1965131,1469670959,0xea674fdde714fd979de3edf0f56aa9716b898ec8,0x3d51978c7b14e486bc7c50c8629b7dc7be6bc405,1.00055988584149
1965131,1469670959,0x447ff4ac930acf585e439de1225fad61389c520e,0xd8e80673419acfbf15bf8eb0239cda90f232051f,32.8088
1965131,1469670959,0x999d1ce359692aebc26cd969a31d47d150128600,0xee48770b4d6fee448b29e2682135147fc059f794,62.219
1965131,1469670959,0x7e12d318239d70a532479b28baa47ec9c4bf83e6,0x556b5712c2a7cc5506fbfa785b52536fb8243765,4000.0
1965131,1469670959,0xf34005bd3186e3ef3ca3452cdd6bb4a7903b1917,0x86290290772671cbd13f1163225e624c67a4675a,10.0
1965131,1469670959,0xea674fdde714fd979de3edf0f56aa9716b898ec8,0x7c43f10e0ff4d33e36437b15b37c30f0d9407af3,0.242703566135995

but Etherchain for block 1965131 includes an additional transaction for 31 ether resulting from activation of a contract.

Over time this kind of omission from the script leads to some wild discrepancies when calculating balances from the data dump, primarily for those accounts that are recipients in smart contract generated transactions.

How can the script be fixed to include the missing smart-contract generated transactions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.