4

My blockchain development background is in Bitcoin, but it now seems to me that the most dynamic and interesting blockchain platform is Ethereum.

In my quest to grok the Ethereum protocol I'm searching for "hooks" to Bitcoin to ground my understanding. What I mean by that is, I'm trying to find analogous concepts that I can use to anchor my understanding.

The most fundamental element of the Bitcoin blockchain is the UTXO set, this is also (according to my understanding) one of the most salient differences between Bitcoin and Ethereum, that is- the fact that Ethereum operates on a model of Externally Owned Accounts (EOAs) and Contract Accounts as opposed to transactions.

What I'd like to do is locate where this information lives on the geth client and just check it out, examine how it interoperates with the rest of the codebase- this would go a long way toward the furtherance of my comprehension of Ethereum.

I'm open to any pointers, tips, if you feel this question or any of the points I've expressed is/are fundamentally misguided I'd like to hear about it.

1 Answer 1

6

Ethereum does have transactions, which can be used to move Ether from account to account, but can also carry additional data as a payload, and trigger other actions on a smart contract (and could transmit zero Ether in the process). When spending Ether, you don't need to reference the exact input that is being spent in this transaction, only the account that the funds are coming from. Ethereum keeps track of the running account balance of each account as part of it's virtual machine state. At any point in the blockchain, you can compute what an account had as a balance, but you cannot trace the path of an individual Ether or Wei unit through the whole blockchain. More details on UTXO vs Balances can be found in this question

Using the JSON-RPC API, you can query transaction data by using the eth_newFilter action to get just the transactions you care about (probably starting with a fromBlock of zero, and a toBlock of 100, and going by chunks through the blockchain, so you don't overwhelm your geth server with any one API call).

Alternatively you can step through each block in the chain by using the eth_getBlockByNumber action to get the details of a specific block (which includes all the transactions in it). Start at block zero and keep increasing the index value to step through the blockchain.

To use the JSON-RPC API, if you're unfamiliar with command line curl commands, using a tool like Postman can be helpful. Launch Postman, and put your geth server's address in the query line. Set the request type to POST, and under the "Body" tab, set the format to "raw" (and pick "JSON (appliation/json)" for the syntax). Now you're set to put in your RPC request and start querying. As a test to make sure it's working, try this as the request body:

{
  "jsonrpc":"2.0",
  "method":"web3_clientVersion",
  "params":[],
  "id":42
}

Which should come back with a response that gives you the version of the software your node is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.