Hot answers tagged

14 votes
Accepted

Why are there no leading zeroes in ethereum block hash?

In the Ethereum blockchain, the difficulty is used to calculate a target. Here are the ethminer logs for block number 1257006 : ℹ 35:02:42.89 ethminer Solution found; Submitting to http://192.168....
user avatar
14 votes

What is a block hash?

The block header is the hash returned from generating a Merkle tree that is below the current difficulty target for the blocks data. What's a hash? In order to understand what the block header is ...
user avatar
14 votes
Accepted

trying to use web3-utils but not working

Please check your web3.js library version. In versions < 1.0 you can call web3.sha3('test'). In 1.0 it was moved to web3.utils.sha3 Another option is to use web3-utils library, in this case you ...
user avatar
  • 2,896
13 votes
Accepted

Difference between keccak256 and sha3

from an answer to What are the key differences between the draft SHA-3 standard and the Keccak submission?: No they did not, the internals and security levels have not been changed from the ...
user avatar
  • 246
12 votes

How to calculate the assigned txHash of a transaction?

Short answer It cannot be done. Longer answer The txhash is keccak256(signedTransaction). This keccak256 function is available as a solidity function http://solidity.readthedocs.io/en/v0.4.21/units-...
user avatar
11 votes
Accepted

Why are Ethereum addresses hashes of public keys?

Indeed, ethereum's address reuse renders the "protection against an ecc public key attack" argument null. For externally owned accounts, using the public key directly would likely not result in any ...
user avatar
  • 3,800
9 votes
Accepted

What datatype should I use for an IPFS address hash?

bytes because they are more than 32 bytes. An IPFS hash: itself specifies the hash function and length of the hash in the first two bytes of the multihash. In the examples above the first two ...
user avatar
  • 78.3k
9 votes

Why are there no leading zeroes in ethereum block hash?

What you see in block explorers is the sha3 of the block header, not the ethash.
user avatar
8 votes

keccak3 in SOLIDITY and in WEB3 different hashes for an address type field

web3.sha3() takes an encoding parameter to specify that you are passing in a hex address: address_string = '0x5b2063246f2191f18f2675cedb8b28102e957458'; web3.sha3(address_string, {encoding: 'hex'}); ...
user avatar
  • 6,101
8 votes

Block header hash calculation

Below are the steps to calculate blockHash, given a blockNumber: Step1. eth.getBlock(400000) Output:{ difficulty: '6022643743806', extraData: '0xd583010202844765746885676f312e35856c696e7578', ...
user avatar
  • 361
7 votes
Accepted

Does a mining reward transaction have a hash?

There are no inputs and outputs in Ethereum, just state changes and balances. Therefore, mining rewards don't have a transaction hash since they are not a transaction. Each block contains the miner'...
user avatar
  • 34.2k
7 votes
Accepted

How does keccak256 concatenate values inside a Solidity smart contract?

The arguments are expressed as bytes, left-padded with zeroes to the maximum length of the data type you've passed in, and concatenated without any kind of delimiter. In Python, given two hex-encoded ...
user avatar
  • 16.3k
7 votes

block-header hash verification

Below are the steps to calculate blockHash, given a blockNumber: Step1. eth.getBlock(400000) Output:{ difficulty: '6022643743806', extraData: '0xd583010202844765746885676f312e35856c696e7578', ...
user avatar
  • 361
7 votes

Can we use block hash as verifiable randomness for the off-chain lottery?

we want to use the block hash of some block in the future as a seed for the random generator. I think using a future block hash is generally considered "safe". (This article discusses using ...
user avatar
6 votes
Accepted

Distribution of KECCAK-256 hash values

I came across this paper that looks at using Keccak-256 (the original one that Ethereum uses, not SHA3) as a PRNG. It subjects the output of the hash to a large number of tests of randomness and it ...
user avatar
  • 8,652
6 votes

How to calculate the assigned txHash of a transaction?

According to geth source code (file core/types/transactions) and this medium post the hash of a transaction is given by the keccak 256-bit hashing of the rlp encoding of all fields of a transaction, ...
user avatar
  • 1,734
6 votes
Accepted

How to generate the full list of function selectors for a contract?

Maybe you can use the online Ethereum IDE (Remix): Paste the whole code of the address you posted. Select the same compiler version: v0.4.25+commit.59dbf8f1. Select the contract by name: ...
user avatar
  • 2,958
6 votes
Accepted

Solidity's keccak256 hash doesn't match WEB3 keccak hash

The abi.encode function encode its parameters for a contract call using Solidity's ABI specs. For fixed size types like uintXXX, bool, address, it's quite easy, just pad them to 32 bytes; for dynamic ...
user avatar
  • 29.1k
6 votes
Accepted

How to use ethers keccak256?

Let's look at the function definition for keccak256: export function keccak256(data: BytesLike): string { return '0x' + sha3.keccak_256(arrayify(data)); } The input is not a string - it's a ...
user avatar
5 votes
Accepted

How to compare hash of two structures?

The return value of sha256 is bytes32. So use bytes32 a = sha256(...) and do the same for b. This will fix the compiler errors and a == b will work. But currently you cannot pass a struct to ...
user avatar
  • 78.3k
5 votes

Does Ethereum use Ethash or KECCAK-256 (an alias to SHA3) as hash function?

A hash function is different to a proof-of-work algorithm. Much of the effort in following a proof-of-work algorithm involves making hashes, but they're distinct things. Ethash is the proof-of-work ...
user avatar
  • 16.3k
5 votes
Accepted

Price of storing a hash SHA3 in Ethereum and Bitcoin

In Bitcoin, you can store 80 bytes in one transaction with OP_RETURN. SHA-3(256) has a size of 32 bytes and can be stored in one transaction. The fee for the OP_RETURN transaction is 0.0001 BTC. By ...
user avatar
  • 2,038
5 votes
Accepted

Is it possible to have a mapping with a hash as key?

Yes, hash was an old type that's been replaced with bytes32. You can call keccak256(data1, data2, ...) and use that as a key. Prior discussion on hash.
user avatar
  • 78.3k
5 votes
Accepted

Build a hash from a string and a number uint256 on Solidity

Another correction (2019-05-17): In modern Solidity version you can no longer pass multiple arguments to keccak256. It now only takes one argument of type bytes. You can still hash multiple values ...
user avatar
  • 9,057
5 votes
Accepted

How to get the type of transaction (Send/Receive/Approve/Swap) and the ERC20 tokens involved in that transaction?

First, you are not querying the right endpoint. If you want to fetch ERC-20 events, you must do the following query : https://api.etherscan.io/api?module=account&action=tokentx&address=...
user avatar
  • 512
4 votes

Hashes per Ether, before and after PoS

The number of hashes depends on the number of miners that partecipate in a lottery to win the Ether fee. Therefore you can not have a number NoHashes/Eth. The hashing is a way do have a distributed ...
user avatar
4 votes
Accepted

Dangling hash node ref: too many open files

Check Open File Descriptor Limits You may need to increase the Linux file limit to handle the number of connections your nodes are serving. Here are some articles on checking and setting the limits. ...
user avatar
4 votes
Accepted

What is "Universal Hash Time"?

Universal Hash Time is a proof of existence service that you can build on top of a blockchain. To further answer your questions: Purpose: it proves that some data existed at the time a block that ...
user avatar
  • 5,030
4 votes

Save hash data with KECCAK-256 then reverse the process in PHP

Hashing is one-way: If you have text you can create a hash, but if you have a hash you can't use it to recreate the text.
user avatar
  • 16.3k
4 votes

After the gas price, is the transaction hash used to prioritize pending transactions?

In Parity the hash is the an item for the ordering criteria, as you can see here: https://github.com/paritytech/parity/blob/1aaafa2d11b42af6be97754f4bc06e2856904464/ethcore/src/miner/transaction_queue....
user avatar
  • 177

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