Questions tagged [bytes32]

The tag has no usage guidance.

14 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
76 views

Most gas efficient way to check if byte array contains zeroes?

I have a contract that I pass data packed into an array of uint256 (as it's apparently cheaper to use uint256 over bytes32) and each byte in the uint256 contains positions referencing another array of ...
2
votes
0answers
288 views

Comparing solidity sha3 with web3 sha3 inside smart-contract

The problem is that sha3 in solidity returns bytes32 and I have a string returned from IPFS by oraclize, and if hash calculated in solidity and returned to web3js (bytes32 got interpreted as a string) ...
2
votes
0answers
304 views

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 ...
1
vote
2answers
150 views

How to convert string to bytes256 or arbitrary bytes?

I already know how to convert bytes32ToString and stringToBytes32: function bytes32ToString(bytes32 x) public pure returns (string memory) { bytes memory ...
1
vote
0answers
44 views

solidity variables to store decentralized identities keys — bytes32 sufficient for a ED25519 keys?

I am building a next generation decentralized identity solution. Would like to under which solidity variable is best suited to store decentralized identities keys -- bytes32 sufficient for a ED25519 ...
1
vote
0answers
28 views

Gas estimation failed when trying to input a list of bytes32[5]

I am trying to create a struct as shown in the code below. The function setData is intended to create an object of the struct, take the inputs (a string and a list of type bytes32[5]) and set their ...
1
vote
0answers
195 views

cannot get return variable(s) in javascript when using require in solidity

I have a function in solidity that returns a few bytes32 variables. I cannot for the life of me access those variables. Can someone please help? function getData() public returns (bytes32, bytes32, ...
1
vote
2answers
395 views

Invalid Op Code - passing bytes32 array to a contract method called from another method of another contract

I've been banging my head on this one for some hours, I'd appreciate any help :) This is a final edit to clearly state the issue: Is there a proper way to pass a bytes32 array to a method on contract ...
1
vote
0answers
111 views

Solidity extract a sub bytes32 from a source bytes32

I need to extract a sub-bytes32 from a source bytes32 so I wrote this solidity function: function bytesOf(bytes32 source, uint start, uint count) private pure returns(bytes32) { bytes32 result; ...
0
votes
0answers
17 views

How much is the biggest BytesX type in solidity? (Bytes32?)

I'm trying to keep it simple while returning and array of strings. I want to return a fixed bytesX array with small text. How much is the possible X in the BytesX type? In Remix it seems to be Bytes32....
0
votes
1answer
23 views

When using mapping, why use an address over bytes32?

From an end user standpoint, they will never want to use the address for searching for mapped data when they could just submit a username for function parameters, so is there any specific reason why ...
0
votes
1answer
39 views

Combine BytesX and BytesY to create BytesZ?

I am working on a Solidity Smart Contract (^0.5.10) where I want to return an array of Ratings elements. struct Ratings { address restaurant uint8 score }; Since returning Rating[], string[]...
0
votes
1answer
405 views

Setting values of an byte array dynamically

If I set the values of an array as follows, am I wrong? uint256 n = 0; bytes32[n] example; function getArraySize(uint256 arraySize) public returns(uint256 size) { size = arraySize; return size; }...
0
votes
2answers
313 views

Smart Contract with web3j - Stored SHA hash returned is not the same as input

I have a contract that stores sha-256 hashes of documents (stored as bytes32). I also have a method to retrieve a hash that is mapped to a unique id for the document. However, when I retrieve and ...