Skip to main content
83 votes
Accepted

How can I check if an Ethereum address is valid?

Updates (June 2023) web3.utils.isAddress will soon be deprecated. Please use web3-validator package instead. Example: import { isAddress } from 'web3-validator'; isAddress('blah'); Using a Library (...
eth's user avatar
  • 85.8k
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
  • 16k
52 votes

How can I check if an Ethereum address is valid?

There is an easier way now with web3: Naive: https://web3js.readthedocs.io/en/v1.2.0/web3-utils.html#isaddress web3.utils.isAddress('0xc1912fee45d61c87cc5ea59dae31190fffff232d'); > true OR ...
rstormsf's user avatar
  • 4,337
46 votes
Accepted

How to encrypt a message with the public-key of an Ethereum address

thx @Edmunx Edgar, i tried to use ECIES, but it failed to install because of a subdepencency. I now used the bitcore-lib together with bitcore-ecies. This works like expected. EDIT: I created a npm-...
pubkey's user avatar
  • 1,157
20 votes
Accepted

What the difference between Bitcoin and Ethereum private/public keys and address?

Yes and no. No - a Bitcoin address cannot be directly used in Ethereum, and vice versa. Yes - underneath, a bitcoin private key is essentially a random 256-bit number (in a certain range, see ...
Linmao Song's user avatar
  • 2,357
17 votes

EthereumJS: How to get public key from private key

ethereumjs-wallet can be used to get public key from private key: > const hdkey = require('ethereumjs-wallet/hdkey') > const privateKey = hdkey.fromMasterSeed('random')._hdkey._privateKey > ...
max taldykin's user avatar
  • 2,966
17 votes

Get public key of any ethereum account

It is now possible to recover public key from Ethereum transaction without any coding: Open the transaction in Etherscan.io Click on vertical ellipsis in the top-right corner Click on "Get Raw ...
Mikhail Vladimirov's user avatar
16 votes

Ethereum Address vs Public Key

When you are creating a new wallet, what you are doing is creating an account. Every account has a private key and a public key, and are indexed by an address that is where you send the transaction. ...
Olivers De Abreu's user avatar
14 votes

Get public key of any ethereum account

I don't think this is possible, since you lose information when going from public key to address: Start with the public key (64 bytes) Take the Keccak-256 hash of the public key. You should ...
Olmo Ziarko's user avatar
14 votes

Ethereum Address vs Public Key

No specific usecase of public key, As usually one can ask for public key(address) that means informally we sometimes say public key despite of address. An Ethereum address represents an account. ...
Thakur's user avatar
  • 347
13 votes

What the difference between Bitcoin and Ethereum private/public keys and address?

Just to add to the very good accepted answer: Coin | Address size | Address encoding | Address creation ---------+---------------------+------------------+------------------ Bitcoin | ...
Richard Horrocks's user avatar
12 votes

How to encrypt a message with the public-key of an Ethereum address

Assuming you have the public key of the person you want to send a message to (if they've already signed a transaction you can recover it from the signature) it should be possible to encrypt and ...
Edmund Edgar's user avatar
  • 16.9k
11 votes
Accepted

Location of public and private keys of Ethereum account

Some of the links in the comments helped me get the answers to my questions. I have collected all that information combined with my own (recently acquired) knowledge of cryptography from the Coursera ...
Ajoy Bhatia's user avatar
  • 1,446
11 votes

Ethereum Address vs Public Key

Ethereum security model relies on elliptic curve cryptography (ECC) to sign and validate transactions. In ECC public and private key are used to sign and verify. It has no concept of addresses. When ...
Ismael's user avatar
  • 30.6k
11 votes
Accepted

The difference between contract address and wallet address

An account address - either an externally owned account (what you're calling a wallet), or a contract account - isn't the same thing as a memory address. It's not possible to know what exists at "...
Richard Horrocks's user avatar
10 votes
Accepted

Get address from public key in Solidity

This works: return address(keccak256(publicKey) & (2**(8*21)-1)); 2**(8*21)-1 is just a trick to get 0xFFFFFF... (40 Fs) without typing it. :-) EDIT As pointed out by @schnorr, there's no need ...
user19510's user avatar
  • 28k
9 votes

How can I check if an Ethereum address is valid?

The standard 40 character hex addresses now have a checksum in the form of capitalization. If the address has at least one capital letter then it is checksummed and, if inputted on a site that checks ...
tayvano's user avatar
  • 16k
8 votes

How can I check if an Ethereum address is valid?

function validateInputAddresses(address) { return (/^(0x){1}[0-9a-fA-F]{40}$/i.test(address)); }
Stepan Poperechnyi's user avatar
8 votes

Is it possible to tell that two addresses were derived from the same private key?

Technically, a private key will only lead to two addresses - one from the hash of the uncompressed public key, and one from the compressed on. Ethereum only uses uncompressed keys, so you only get one ...
Raghav Sood's user avatar
  • 4,040
8 votes
Accepted

web3py: get public key from private key (without prior transaction)

If you want convert private key to public key and not address, then I would recommend using eth-keys library. It is in the dependencies of eth-account library, which is in the dependencies of web3py. ...
Pavel Kondr's user avatar
8 votes
Accepted

Convert EOA to contract account

The issue is in your assumption that they mean convert an EOA to a contract. Yes, deploying a contract to the same address that you have a private key to would be, practically speaking, impossible. I ...
natewelch_'s user avatar
7 votes

The difference between contract address and wallet address

In Javascript, EOA(wallet address): '0x' + keccak256(publicKey).slice(-40) Like above, wallet address can be achieved by public key. 1) hash it with keccak256. 2) slice rightmost 20 bytes(40 words). ...
nujabes's user avatar
  • 191
6 votes
Accepted

Get public key of msg.sender in a smart contract

Contracts cannot access the public key of the sender, since the raw transaction data is not visible to contracts. However, given the public key, you can verify that it does in fact match the address ...
Tjaden Hess's user avatar
  • 37.1k
6 votes

Ethereum Address vs Public Key

I believe there is no practical use of the public key. Because of this, in most account creation tools, the public key is never even displayed to the user. (You could use the public key to encrypt a ...
user19510's user avatar
  • 28k
6 votes
Accepted

Why are the last 20 bytes of the public key used as the address?

Full public keys aren't really that useful in Ethereum*, as they don't serve any practical use. Taking the last 20 bytes is a: Heuristic aimed to simplify the management of the key; that is, copy and ...
Paul Razvan Berg's user avatar
6 votes
Accepted

How to convert public key (64 bytes) to compressed public key (33 bytes)

There's a package that contains suitable functions, here -> pubkey/eth-crypto See: publicKey.compress(), and publicKey.decompress() The compress code is below. (Copy + pasted from this file.) var ...
Richard Horrocks's user avatar
5 votes

Get public key of any ethereum account

Using @tayvano hint, you can do it as follows: Go to etherscan, and check if there are outgoing transactions: https://etherscan.io/address/0x54dbb737eac5007103e729e9ab7ce64a6850a310 Get hash of one ...
tworec's user avatar
  • 173
5 votes
Accepted

Does ethereum support something like bip32 extended public key?

Yes. This is typically how the Mnemonic code for generating deterministic keys (BIP39) protocol works. The user generates a 12/24-word Wordlist, eg: power foster height puppy palm swing slight rain ...
Shomari's user avatar
  • 625
5 votes
Accepted

Find the public key of any ethereum account (that hasn't signed a transaction)?

Without a signature, there's no way to get the public key (short of someone giving it to you). So for an address that has never made a transaction, this can't be done. (I'm not sure where ...
user19510's user avatar
  • 28k
5 votes

How to generate multiple eth-addresses from one private key?

One way is to use a deterministic hierarchal wallet (originally from Bitcoin BIP-32), e.g. the Light Wallet, see a related question here. In this way, the private key becomes the "master" private key, ...
Linmao Song's user avatar
  • 2,357

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