191 votes
Accepted

How are ethereum addresses generated?

Recently this article came to my attention that is way more in depth and technical than my more accessible version below. It also walks you through how to generate one on your own. I highly recommend ...
tayvano's user avatar
  • 15.9k
70 votes
Accepted

Get public key of any ethereum account

You can if and only if a transaction has been sent from the account. When you send a tx, you sign the transaction and it includes these v r and s values. You parse these from the signed tx and then ...
tayvano's user avatar
  • 15.9k
66 votes
Accepted

What is nonce in Ethereum? How does it prevent double spending?

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: ...
Achala Dissanayake's user avatar
55 votes
Accepted

How does a contract find out if another address is a contract?

This works: function isContract(address _addr) private returns (bool isContract){ uint32 size; assembly { size := extcodesize(_addr) } return (size > 0); } The assembly language that ...
Thorkil Værge's user avatar
53 votes
Accepted

Do contracts also have a nonce?

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 ...
eth's user avatar
  • 85.4k
53 votes

What is an 'EOA' account?

This is an Externally Owned Account, so your normal Ethereum address, not a wallet contract. In general, there are two types of accounts: externally owned accounts, controlled by private keys, and ...
Roland Kofler's user avatar
48 votes

How do I backup my ether accounts?

To backup your wallet you will need to make a copy of the key file(s) located in your ethereum directory. Linux: ~/.ethereum/keystore Mac: ~/Library/Ethereum/keystore Windows: %APPDATA%/Ethereum ...
Ethan Wilding's user avatar
46 votes
Accepted

How to backup mist wallets?

How to Access the Files to Back Up Using Mist - Backup Accounts Go to the top bar and select ACCOUNTS -> BACKUP -> ACCOUNTS. This will open a folder. Inside this folder there are keystrore files ...
tayvano's user avatar
  • 15.9k
43 votes
Accepted

How can I create a multisignature address on Ethereum?

"Multisignature" addresses on Ethereum differ from that of Bitcoin. Though both networks allow for arbitrary complex transactions, the concepts are not intrinsically the same: In Bitcoin, there are 2 ...
Taylor Gerring's user avatar
43 votes
Accepted

Why don't Ethereum addresses have checksums?

Edited to add: As predicted, with the launch of the Ethereum Name Service (ENS), users and wallets have gradually begun switching over to using strings like "mywallet.eth" instead of the raw hex ...
Jeff Coleman's user avatar
41 votes
Accepted

What's the difference between Accounts and Wallets in Mist?

Accounts are the most basic way to store Ether. They are simple public/private keypairs, which you use to sign transactions. You don't need to do anything to "register" an account with the network, ...
Tjaden Hess's user avatar
  • 36.9k
36 votes
Accepted

How can I detect change in account in Metamask?

As suggested by Metamask FAQs this might be an option: var account = web3.eth.accounts[0]; var accountInterval = setInterval(function() { if (web3.eth.accounts[0] !== account) { account = web3....
qbsp's user avatar
  • 4,357
34 votes

What is coinbase?

Crypto currencies and blockchains in general allow you to work with arbitrarily many accounts at the same time. However often people want to have a default/primary account (e.g. miners have a ...
Péter Szilágyi's user avatar
34 votes
Accepted

In the truffle console, how to set and get current account?

In truffle console: var accounts; // in web front-end, use an onload listener and similar to this manual flow ... web3.eth.getAccounts(function(err,res) { accounts = res; }); var account1 = ...
Rob Hitchens's user avatar
34 votes

How can I detect change in account in Metamask?

From the MetaMask docs: window.ethereum.on('accountsChanged', function (accounts) { // Time to reload your interface with accounts[0]! }) window.ethereum.on('networkChanged', function (networkId) { ...
rstormsf's user avatar
  • 4,337
34 votes
Accepted

Difference between Ganache and Truffle

Ganache allows you to create a private Ethereum blockchain for you to run tests, execute commands, and inspect state while controlling how the chain operates. It gives you the ability to perform all ...
Shane Fontaine's user avatar
27 votes
Accepted

Can I use the same private key for Ethereum and Bitcoin?

Yes, both cryptocoins use the same elliptic curve SECP256K1. Perhaps a better alternative is to use a BIP32 wallet. You have a master key that is not directly used for transactions, but it is used to ...
Ismael's user avatar
  • 30.5k
25 votes
Accepted

What is a replay attack?

A replay attack is a valid data transmission that is maliciously or fraudulently repeated or delayed. Extending this to blockchains, a replay attack is taking a transaction on one blockchain, and ...
eth's user avatar
  • 85.4k
23 votes

How does a contract find out if another address is a contract?

Full credit to @AnAllergyToAnalogy for the caution item. I made an example to demonstrate that a constructor will trick this method. Posting for others who might come across this thread. In practice, ...
Rob Hitchens's user avatar
23 votes

How can I detect change in account in Metamask?

Using web3 version 1.0.0, the metamask provider exposes an 'update' event you can listen to on it's publicConfigStore. web3.currentProvider.publicConfigStore.on('update', callback); Your callback ...
Brian Ethier's user avatar
21 votes
Accepted

How does the Ethereum ETH accounting system work and prevent double-spends?

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 ...
eth's user avatar
  • 85.4k
21 votes
Accepted

Concurrency patterns for account nonce

I haven't yet got to the point where I can test any of these things, but my gut feel is that the Singleton Nonce Manager would be the way to go, with a few enhancements: Make it a singleton ...
Sentinel's user avatar
  • 1,238
20 votes
Accepted

How do I remove accounts using the Geth console?

You can't remove account. You need to remove them directly from your keystore folder. IT IS IRREVERSIBLE. ~/Library/Ethereum/keystore I feel the need to repeat that once the file is deleted it's ...
jayD's user avatar
  • 2,462
19 votes
Accepted

How to validate a private key?

As mentioned by Peter, a private key is a random 256 bit blob. It is a common oversight that there're no restrictions. It has to be valid for the secp256k1 curve, which means two conditions: cannot ...
axic's user avatar
  • 2,569
18 votes

How do I backup my ether accounts?

PLEASE MAKE SURE TO ALSO BACKUP YOUR PASSWORDS Each key file (as described in @Ethan's answer) is encrypted and only usable with the correct password. Another safety tip: Before deleting any key ...
eth's user avatar
  • 85.4k
18 votes
Accepted

Ethereum Vanity Address generators

This is a community wiki of vanity address generators, sorted by name. NOTE ! You should always check that you can use your newly generated addresses before sending any significant amount of ethers ...
18 votes
Accepted

How to unlock accounts programmatically after the node has started?

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 ...
BokkyPooBah's user avatar
  • 40.3k
18 votes

Account uniqueness guaranteed?

Ethereum addresses are 160 bit hashes, meaning there are 2^160 possible hashes. Per the birthday problem, the chance of a collision rises to 50% when there are about 2^80 accounts created. To give ...
Nick Johnson's user avatar
  • 8,144
18 votes
Accepted

Error "no key for given address or file" when unlocking coinbase account

We were getting the same error and it turned out that there were two conflicting keyfiles. One in the default (~/.ethereum) and one in a custom location that we had specified using --datadir. In the ...
Peter Munnings's user avatar
18 votes
Accepted

isContract function using EVM assembly to get the address' code size

EDIT: The function will return false if it is invoked from a contract's constructor (because the contract has not been deployed yet). The code should be used very carefully, if at all, to avoid ...
eth's user avatar
  • 85.4k

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