135

There are a few trade-offs and key points to keep in mind in this area. Any decision that a user makes which affects the outcome gives that user an unfair advantage. Examples include: Using a blockhash, timestamp, or other miner-defined value. Keep in mind that the miner has a choice of whether to publish a block or not, so they could conceivably have one ...


75

address.transfer() throws on failure forwards 2,300 gas stipend (not adjustable), safe against reentrancy should be used in most cases as it's the safest way to send ether address.send() returns false on failure forwards 2,300 gas stipend (not adjustable), safe against reentrancy should be used in rare cases when you want to handle failure in the contract ...


70

The Ethereum blockchain was designed to be entirely deterministic. This means, that if I took the whole history of the network, then replayed it on my computer, I should always end up with the correct state. Since the internet is non-deterministic and changes over time, then every time I replayed all of the transactions on the network, I would receive a ...


39

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.


39

Nothing prevents it. 5 months ago, I demonstrated storing audio (a very highly compressed mp3 file) in the blockchain. And it's still there and being replicated by every full node today! Only 3.5kB and I had to pay quite a bit of ether, but still cool! Check out Freakiest thing ever - the blockchain now has a voice! thread at Reddit. To make this answer ...


37

A Simpler Explanation The attacker creates a wallet contract (0xc0ee9db1a9e07ca63e4ff0d5fb6f86bf68d47b89 in the 17/06/2016 attack) with a default (or fallback) function () to call The DAO's splitDAO(...) function a number of times. Following is a simple default function (): function () { // Note that the following statement can only be called ...


35

AFAIK the best way to do this at the moment is to compile the source code again with the exact same compiler version the author used (so this is something that needs to be disclosed) and to compare the bytecode. So the match you should check is the compiled bytecode against the data of the contract creation tx.


35

Both send and transfer are considered to be a safe way to move funds as they have a gas stipend of 2300. If you are curious about the reasons for adding a transfer you may follow an original discussion about the feature. EDIT Dec 2019: call.value()() should now be used for transferring ether. (Do not use send or transfer.) Please see: Is transfer() still ...


34

Not especially, but it depends on what the use case is. Block times are subject to the following constraints: If you stamp your block with a time too far in the future, no one else will build on it (miners will not build on a block timestamped "from the future"). Your block time cannot be stamped with an earlier time than its parent. Difficulty is kept ...


33

(Please edit me. I'm a community wiki) Summary Don't allow TCP request on port 8545 from the Internet to be forwarded to your geth machine Don't enable --rpc without checking that only your GPU mining computers can access TCP port 8545 on your Ethereum node geth computer Don't run the Ethereum Wallet on the same machine as your geth computer. If you need a ...


30

The primary things "stopping you" would be: Block gas limits which are currently "voted on" by miners Amount of gas you would need to pay to store your data Things like baby photos are going to be, at minimum, 600kB uncompressed. I am not incredibly familiar with image compression, so we will just work with the 600kB figure for the sake of example. A ...


28

First, a note on safety: You should not make the personal API available over RPC If you are on a local, trusted machine, you should use IPC instead of RPC. Otherwise, anyone who can connect to your node via RPC can try to brute-force your passwords and steal your Ether. All administrative APIs are available by default over IPC, so no need to use any flags ...


26

Oraclize stores the TLSnotary secret in an Amazon Web Services (AWS) Virtual Machine. Using the techniques described here, they are able to provide some additional guarantees regarding the software running in the AWS instance and when/whether it has been modified since being initialised. The "proofs of honesty" they provide (and allow you to verify with ...


26

You can actually take in data from the internet. You just need someone to hand it to your contract. How can you trust that person? Use something like Provable. https://provable.xyz This is an idea that uses TLS Notary to guarantee the answer is authentic from the web server. I found it because I was originally thinking of doing the same thing with TLS ...


24

Cold storage has been discussed in the past on Ethereum's subreddit. Just to give my 2 cents, on Ubuntu I use the following on the command line: cat ~/.ethereum/keystore/<key_file> | qrencode -o qr_image.png Add option -l H to get a code that is easier to decode. The qrencode tool uses the open source libqrencode library, and can be installed using: ...


24

Just to clarify, the "trivial solution" referred to is about how to produce a series of random numbers from a single random seed. As a general rule, BLOCKHASH can only be safely used for a random number if the total amount of value resting on the quality of that randomness is lower than what a miner earns by mining a single block. To see why this is the ...


22

The geth client waits 5 blocks for confirmation of fresh minted blocks (around 1 minute). I0201 19:07:07.354260 9098 worker.go:349] 🔨 Mined block (#1483 / a2648b58). Wait 5 blocks for confirmation To make sure a block is no uncle or a transaction included in a block does not hang up in an ommer, I would suggest waiting 7 confirmations (around 2 ...


22

The following opcodes trigger a refund SELFDESTRUCT SSTORE[x] = 0 (i.e. deletion) SELFDESTRUCT refunds 24.000 and SSTORE clear refunds 15.000 gas. The accumulated refund can not exceed half the gas used for the current context (i.e. the initial call). Let's take the following example: Current state of the contract's storage 0x00: 1 0x01: 1 And the ...


21

Note that with linagee's suggestion, you're not just trusting random.org, you're also trusting Oraclize. Oraclize publish a TLS notary proof to show that the data they're giving you really came from random.org, but that's not enough for this case: We need to know that this was the only data they got from random.org. Otherwise they could keep trying and ...


21

If a full-frontal and obvious 51% attack occurs, the live Ethereum network will essentially have failed. There is no real way to protect against this eventuality other than to watch for orphan rates to spike and then immediately notify everyone that the network is unreliable. The main thing protecting the Ethereum network (and the Bitcoin network, and any ...


20

From my reading of the Yellow Paper (YP), Yes you would be able to spend the funds of the contract. But as you note, it is with extremely low probability of being able to find a contract's private key. Spending money in Ethereum is done via a CALL opcode, passing it parameters such as the sender, recipient, value (being spent). Since you have the private ...


19

To add to @thomas-bertani's answer, today etherchain.org released a verification tool for Ethereum contracts Here's the text from the page: Source code verification provides transparency for users interacting with smart contracts. By uploading the source code, Etherscan will match the compiled code with that on the blockchain. Just like contracts, ...


19

Currently, Ethereum uses elliptic curve cryptography, which is not quantum resistant. In the upcoming Serenity upgrade, however, accounts will be able to specify their own scheme for validating transactions, so individuals could choose to use Lamport signatures or other quantum proof algorithms. The Serenity blog post has a more in depth look at account ...


19

Since all transactions and data on the blockchain are public, you need to encrypt the data outside of Ethereum and insert the already encrypted data. Similarly you need to pull the encrypted data and decrypt it locally. I'm sure there are a lot of crypto libraries for javascript that will allow you to do this, web3 I doubt contains such functionality as it's ...


19

The common pattern is called an oracle. Ethereum contracts cannot communicate directly with the outside world, so they must rely on the outside world pushing information into the network. You have 2 choices: Use an oracle: Services like Oraclize are formal implementations where you pay to poke their services for oracle data that they provide. Write an ...


18

Just to clarify: You would like to run a geth node starting up with the accounts all locked as per the default You later want to run a 'geth attach' command to unlock one or more accounts for a period of time You can use use the following command to attach to your geth node to unlock an account using the personal.unlockAccount(...) JavaScript API (https://...


18

This is the community wiki (no reputation) answer for possible attacks and how to protect against them. Feel free to update the list. If your contract functions have characteristics matching prerequisites carefully evaluate your function against given advice. This is the list of potential attacks or mispractices enabling those attacks only. For additional ...


18

Your calculations are right, except there aren't exactly 2^256 private keys -- there are "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141" (this number is named N in the ETH source code, and is the order of the generator of the elliptic curve secp256k1, from which Ethereum key pairs are generated). In answer to your question, yes, ...


17

Updated answer per 4 Jan 2018 Web3.js has full-fledged support for accounts management starting at v1.0.0, including creating a new account. v1.0.0 is still in beta, but is close to production and is already the version released through npm. Thanks Thom Ives for pointing this out. Full example sourced from web3.js documentation: web3.eth.accounts.create();...


17

Each account has a globally accessible nonce which prevents same-chain replay attacks and double spends. The nonce is the sequence number, which miners check, because a block that has a transaction with an incorrect nonce is an invalid block (other miners won't build on top of it). (The nonce does not protect against cross-chain replay attacks.) Second ...


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