335

"Gas" is the name for a special unit used in Ethereum. It measures how much "work" an action or set of actions takes to perform: for example, to calculate one Keccak256 cryptographic hash it will take 30 gas each time a hash is calculated, plus a cost of 6 more gas for every 256 bits of data being hashed. Every operation that can be performed by a ...


204

Call A call is a local invocation of a contract function that does not broadcast or publish anything on the blockchain. It is a read-only operation and will not consume any Ether. It simulates what would happen in a transaction, but discards all the state changes when it is done. It is synchronous and the return value of the contract function is returned ...


93

Summary Transactions with too low a nonce get immediately rejected. Transactions with too high a nonce get placed in the transaction pool queue. If transactions with nonces that fill the gap between the last valid nonce and the too high nonce are sent and the nonce sequence is complete, all the transactions in the sequence will get processed and mined. When ...


81

With msg.sender the owner can be a contract. With tx.origin the owner can never be a contract. In a simple call chain A->B->C->D, inside D msg.sender will be C, and tx.origin will be A. msg.sender is preferred for the flexibility it provides. Furthermore, for Serenity, even though it's a while out, Vitalik recommends avoiding tx.origin: How do I make my ...


71

In earlier versions, we would apply the constant modifier to indicate that a function doesn't change the storage state in any way. For example: pragma solidity 0.4.16; contract UseConstant { string greeting; function UseConstant() public { greeting = "Hello"; } function SayHello() public constant returns(string says) { ...


67

Wow this is such an interesting question! TL;DR: the transaction size limit, at the time of writing, is about 780kB (about 3 million gas). But read on. There is no direct or fixed limit neither for transaction sizes nor for block sizes. This is a strength of the Etherem network, it does scale. That does not mean that there are no limits. There is the block ...


59

There's not currently any way to do this using the web3 API. Internal transactions, despite the name (which isn't part of the yellowpaper; it's a convention people have settled on) aren't actual transactions, and aren't included directly in the blockchain; they're value transfers that were initiated by executing a contract. As such, they're not stored ...


58

Update Oct 21 2017 There are some changes with the Byzantium fork - getTransactionReceipt(...).status now returns 0 for a failed transaction and 1 for a successful transaction. EtherScan.io displays this status in the TxReceipt Status: field for transactions. See How do I detect a failed transaction after the Byzantium fork as the REVERT opcode does not ...


54

What is nonce in Ethereum? If you refer to the Glossary at Github Wiki, there are two types of nonce used in Ethereum. Account nonce - It's simply the transaction count of an account Account nonce: a transaction counter in each account. This prevents replay attacks where a transaction sending eg. 20 coins from A to B can be replayed by B over and over to ...


53

estimateGas works by pretending the transaction was actually being included in the blockchain, and then returning the exact gas amount that would have been charged if that pretend operation was real. In other words, it uses the exact same procedure a miner would use to calculate the actual fee. Given this approach, a casual observer might think that there ...


46

The following response is taken from Ethereum, Gas, Fuel & Fees What is Gas? Gas is the metering unit for use of the Ethereum "World Computer". As an analogy, electricity is metered by kilowatt hours. Using more computation and storage in Ethereum means that more gas is used. One fundamental reason for metering is that it provides an incentive for ...


46

Summary After the Byzantium fork, eth.getTransactionReceipt(...) will return a status field. The status field has a value of 0 when a transaction has failed with the REVERT opcode and 1 when the transaction has succeeded. Update Oct 10 2017 Responding to the comment by @thomas-jay-rush, when a transaction fails for a reason other than REVERT (i.e. THROW), ...


43

Yes, contracts have nonces. EIP 161 made the contract nonce start at 1, and before EIP 161 the nonce would start at 0. A nonce of a contract is only incremented when that contract creates another contract (@zanzu's YP reference). When a contract invokes a function on another contract, a so called "internal transaction" (in http://live.ether.camp), the ...


42

From George Hallam: 12 confirmations; however, exchanges and entities handling very large amounts of Ether frequently are still encouraged to run two different Ethereum implementations and only accept transactions that have been confirmed by both for maximum security (e.g. Go & C++). For reference, 12 confirmations is approximately 3 minutes.


40

The difference between in a call and a transaction is the following: transactions are created by your client, signed and broadcasted to the network. They will eventually alter the state of the blockchain, for example, by manipulating balances or values in smart contracts. calls are transactions executed locally on the user's local machine which alone ...


39

Contracts do not possess private keys in the same way that your ether wallet does. Instead, they have programming code written in the language of the Ethereum Virtual Machine. To determine what a contract "does", all members of the Ethereum network simply run the relevant portion of code every time a transaction or other contract uses the contract's ...


38

(I was sure this had been asked before, but I can't see it. Please flag as duplicate if you find it... ) What is the difference between now and block.timestamp? Nothing. They're aliases. From the documentation: now (uint): current block timestamp (alias for block.timestamp) Update: (Thanks @ShaneFontaine) Solidity 0.7.0 deprecated the now keyword. For ...


37

At present the user initiating the transaction must pay the fee. However Serenity is likely to enable 'contract pays' schemes. (See Vitalik's blog post here) A possible work around is a contract which refunds the sender however this would still require the user to hold some Ether and might allow malicious parties to repeatedly call the contract to deplete ...


37

I have been running into this issue as well. The network thinks you are trying to replace an existing unmined transaction. There are two ways to avoid this: Adding a gas price %10 higher than the existing unmined transaction's gas price. Increase your nonce to one higher than the unmined transaction. I have also been getting this error: "Transaction was ...


36

The main validation constraints in a Bitcoin UTXO system are: every referenced input must be valid and not yet spent the transaction must have a signature matching the owner of the input for every input the total value of the inputs must equal or exceed the total value of the outputs By contrast functionality in an Ethereum account-based system are: a ...


36

v, r, s are the values for the transaction's signature. They can be used as in Get public key of any ethereum account A little more information, r and s are outputs of an ECDSA signature, and v is the recovery id. https://bitcoin.stackexchange.com/questions/38351/ecdsa-v-r-s-what-is-v also applies to Ethereum. For replay attack prevention, Ethereum ...


35

An Ethereum transaction - as in, what you pass to sendRawTransaction() - consists of the following fields, in order and RLP-encoded (note that the field names are not part of the encoded data): nonce - transaction sequence number fr the sending account gasprice - price you are offering to pay startgas - maximum amount of gas allowed for the transaction to - ...


33

It can't be canceled, but it can be "out-gassed". You can grab the nonce (can be found on the pending tx on etherscan) and send another transaction with a higher gas price with the same nonce. If you use a different nonce, then they can both be mined, but if you use the same nonce, only one can be mined. If miners see both, they should be smart enough to ...


31

Here you have all the global variables in Solidity: Global Variables block.coinbase (address): current block miner’s address block.difficulty (uint): current block difficulty block.gaslimit (uint): current block gaslimit block.number (uint): current block number block.blockhash (function(uint) returns (bytes32)): hash of the given block - ...


29

With an exception, as with throw, all effects (including events) of a transaction are reverted, except for the payment to the miner. So there would be no benefit in firing an event before a throw. Possible Alternative If full reversion via an exception isn't required, an error code might be usable. Example: contract C { function foo() returns(int) { ...


28

Try setting web3.eth.defaultAccount = eth.accounts[0] It sounds like your transaction doesn't know what account to use to sign the call. Any call that changes the state of the contract (write operation) requires a signed transaction. An alternative approach would be to pass a 'transaction object' as the last argument to contract method: storage.set(10,...


28

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 ...


28

There is no fixed gas price that transactions must have. You can specify the gas price, and if you set a gas price within certain bounds, the transaction will be accepted by miners using their default values and oracle. The default gas price is now 0.02 microether which is equivalent to: 0.00000002 Ether (.02 * 1e-6) 0.02e12 wei 20000000000 wei 20e9 wei ...


28

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 ...


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