38

Do this: You'll need to pull code from web3, and it works best if your frontend is bundled using something like webpack or browserify: var SolidityCoder = require("web3/lib/solidity/coder.js"); var log = receipt.logs[0]; var data = SolidityCoder.decodeParams(["string", "uint"], log.data.replace("0x", "")); In this case, we're decoding log data that ...


36

Events in the ethereum system must be easily searched for, so that applications can filter and display events, including historical ones, without undue overhead. At the same time, storage space is expensive, so we don't want to store a lot of duplicate data - such as the list of transactions, and the logs they generate. The logs bloom filter exists to ...


26

First of all, let's understand what is the cumulative gas used. cumulativeGasUsed: Number - The total amount of gas used when this transaction was executed in the block. As suggested by JavaScript API. That explanation was not clear to me at all, let's try another one: cumulativeGasUsed is the sum of gasUsed by this transaction and all preceding ...


23

Relationship between Transaction Trie and Receipts Trie provides a good summary: Transaction Receipts record the transaction outcome Here is the Structure of a transaction receipt blockHash: String, 32 Bytes - hash of the block where this transaction was in. blockNumber: Number - block number where this transaction was in. transactionHash: String, 32 ...


13

Transaction Tries and Transaction Receipt Tries are indeed independent data structures with distinct roots stored on the blockchain header and differ in both purpose and content. Purpose: Transaction Tries: records transaction request vectors Transaction Receipt Tries: records the transaction outcome Content: Parameters used in composing a Transaction ...


12

This was described by EIP 658 which was implemented in the Byzantium fork. The text of the EIP is here, though strangely it doesn't seem to have been formally finalised before the fork. In any case, the relevant text is this: For blocks where block.number >= METROPOLIS_FORK_BLKNUM, the intermediate state root is replaced by a status code, 0 indicating ...


12

Tim: Thanks so much for the pointer. You forced me to finally understand some of the internals of web3.js. I found a cleaner way to do this that covers all the corner cases of the actually fairly complicated log message format (e.g. indexing). I just used SolidityEvent from web3 to do the already-tested work for me. Below is the code. I have this code ...


12

https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgettransactionreceipt Returns Object - A transaction receipt object, or null when no receipt was found: blockHash: String, 32 Bytes - hash of the block where this transaction was in. blockNumber: Number - block number where this transaction was in. transactionHash: String, 32 Bytes - hash of the ...


10

It's the hash of the root of the state trie, whereas receiptRoot is the hash of the array of receipts for a given block. root In GetTransactionReceipt() in api.go there's set of mappings, one of which is: "root": common.Bytes2Hex(receipt.PostState), Looking at receipt.go, PostState is a byte array: // Receipt represents the results of a ...


8

Update: https://github.com/PISAresearch/event-proofs has some code. From its readme: Event proofs A POC to explore how Ethereum logs could be verified in a smart contract. Proofs are generated using eth-proof and verified using the Merkle Patricia Tree implementation from Peace Relay. If running the tests against Infura be patient with them as ...


6

No, they are not the same thing. The Bloom filter in the transaction (R_b) contains only the logs from this transaction while the Bloom filter in the block header (H_b) contains the logs from all transactions in this block. So yes, the information is stored twice, but with the benefit of being able to check quickly if a certain log is present in a block ...


6

A contract is created (also called deployed) by sending the contract's byte code to Ethereum address 0x0 (that is, the to field will be 0x0). If the contract creation succeeds, then (and only then) will there be a value in the contractAddress field of the transaction's receipt. That value will the the address of the newly created contract. Subsequent calls ...


6

You can now use the web3.eth.abi.decodeLog function (web3 1.0). Example from the documentation: web3.eth.abi.decodeLog([{ type: 'string', name: 'myString' },{ type: 'uint256', name: 'myNumber', indexed: true },{ type: 'uint8', name: 'mySmallNumber', indexed: true }], '...


5

Yes, transaction parameters are public once you send them in a transaction. For example, in the following transaction: https://etherscan.io/tx/0x1b9a71a905ab5afe59753c4bad6b84b71ed897a968c88658e1c524b3882fa2a4 yoou can see the Input Data field: Function: transfer(address _to, uint256 _value) MethodID: 0xa9059cbb [0]:...


4

When a transaction is mined, the receipt is available for use, at this point confirmation number is 0, as more block are added to the blockchain, confirmation number increases. With higher confirmation number, we will have more confidence that transaction is on the longest path and can’t be undone. Suppose you accept transactions with a certain number of ...


3

The state trie contains the balance of each account. Even transactions that throw an exception result in a reduction in the sender's balance through gas costs, which means that the resulting state is different from the initial state. An interesting question would be to see if a transaction with a gas price of 0 can be excluded from a block without changing ...


3

In https://blog.ethereum.org/2015/11/15/merkling-in-ethereum Vitalik Buterin gave an example of using the different trees (transactions, receipt, state trees). Has this transaction been included in a particular block? Tell me all instances of an event of type X (eg. a crowdfunding contract reaching its goal) emitted by this address in the past 30 days What ...


3

For web3.js 1.0 use the following: contractInstance.inputs = [{"indexed": false, "name": "_id", "type": "uint256"}]; //event abi contractInstance._decodeEventABI({data: '0x0'}); //event raw data output { returnValues: Result { '0': '1', _id: '1', }, raw: { data: '0x0' } }


3

Most of the protocol (and more particularly the transaction receipt) is consensus critical. The amount of information it handles need to be as much as possible limited and stable. An error message doesn't really fit those requirements. On the other hand, implementations can easily bubble up that sort of information. At least both Ethereumj and Geth do so. ...


3

Q is to being null enough to distinguish a transaction as one that deployed a contract? Yes Q is looking at the receipt the only way to get the address of the contract? Yes, in the go-ethereum client. , although you can probably work out the contract address from the trace results of the debug.traceTransaction(...) API call as well. EDIT: I searched ...


2

Suggestions: A. You can wait for further block confirmations before writing to your database. It's like being X minutes behind, so that you don't have to deal with a chain reorg. See What number of confirmations is considered secure in Ethereum? and note one of the answers is to combine waiting and use multiple clients. B. If you want to deal with chain ...


2

TLDR: There is no easy way or API to get the msg.sender for (internal) message calls. In the Ethereum protocol there's only transactions and message calls. A transaction is a type of message call, and both tx.origin and msg.sender will always be the value of the from field. A transaction may perform other message calls, but these are not transactions (...


2

For ETH, you can check the amount the smart contract received without having to call any smart contract method, using any block explorer. Programmatically, using an Ethereum node, you can call the eth.getBalance(<your address>) method to find the ETH balance of any address (including smart contracts). For ERC20 tokens, you have to call the balanceOf(...


2

You could sign a message hash using the private key of the account that received the transaction. ecrecover can be used to verify the signature was generated from that account.


2

If the transaction failed then you will not lose the 1 ether value, the only cost is the fee (0.00084184 Ether in this case). You should NOT use your coinbase account (or any other exchange for that matter) to interact with smart contracts. Coinbase may not hold a separate account with your funds in, they are likely pooled together in an account with many ...


2

If you call smart contract A, and it calls smart contract B, and smart contract B fails, it is up to smart contact A how to handle that. In most reasonable cases, the only sane action is for smart contact A to abort (and this is the default in Solidity), but it doesn't have to, and can continue, and complete successfully (for its definition of successfully). ...


2

You can easily achieve this using ProvenDB. Here is an example code written in Go to continuously prove your logs' existence and ownership on Blockchain: https://github.com/SouthbankSoftware/provenlogs. Hope it helps :P


2

I was trying to solve this exact problem and wrote a proof of concept that can do this: https://github.com/figs999/Ethereum/blob/master/EventStorage.sol Basically, you need two components: 1: A way to read and confirm the validity of a block header 2: A way to check the bloom filter for the presence of a log entry In my proof of concept, in order to ...


2

From the Ethereum's Yellow Paper the transaction receipt stores information that results from executing the transaction. It is a tuple with four fields Block's cumulative gas used Logs produced during transaction execution Bloom filter from the logs Status code from transaction execution The purpose of the receipt is to provide information to the outside ...


2

Because transactions are identified by their hashes. Transaction hash is calculated on all the fields of the transaction. After transaction is signed, you can't modify it without changing the hash, and if you do that before it is mined, the network takes it as a different transaction. When a transaction creates a contract, the contract address is stored in ...


Only top voted, non community-wiki answers of a minimum length are eligible