Questions tagged [bytes32]

https://docs.soliditylang.org/en/v0.8.13/internals/layout_in_storage.html?highlight=string#bytes-and-string

The value types bytes1, bytes2, bytes3, …, bytes32 hold a sequence of bytes from one to up to 32.
bytes and string are encoded identically. In general, the encoding is similar to bytes1[], in the sense that there is a slot for the array itself and a data area that is computed using a keccak256 hash of that slot’s position. However, for short values (shorter than 32 bytes) the array elements are stored together with the length in the same slot

99 questions
6
votes
3 answers

How can I modify bytes32 result to uint?

I want to separate three last digits of the most recent block header hash and get the result as uint. I can get the answer as bytes32 by this code, but how can I change this result to uint? contract test { bytes32 lastblockhashused; uint…
Matias
  • 1,109
  • 1
  • 10
  • 16
3
votes
1 answer

Is it possible to change an already assigned bytes32 variable?

If I assign a bytes32 variable such as bytes32 x = 0xffff; but then I want to change the last byte (or any byte really) so that x is now 0xffaa, is there any possible way to do this? I want the change to be persistent so that any changes in x are…
jojeyh
  • 769
  • 3
  • 8
2
votes
0 answers

How to pass bytes32 value from javascript?

I am using truffle and Ganache. I wrote the following code in remix and its working. But when I use the same code with javascript I am getting runtime error pragma solidity ^0.4.17; contract Delegation { //Structure definition to store various…
1
vote
1 answer

bytes32 comparison returning true when values are very near

Has this nagging question where bytes32 that are near to each other returns true on comparison. truffle(development)> 0x5b3138302c3132302c3135392c3232332c36342c3135392c36392c323821311a ==…