Questions tagged [data-types]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
31 views

How are we able to send 512 bit hash as a bytes32 variable?

I have a code that is working: solidity function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) { bytes memory prefix = "\x19Ethereum Signed ...
1
vote
1answer
26 views

is there a list type in solidity?

I know there are dynamically sized arrays, but I need a data structure that can remove elements from the middle cheaply. Using pop() with a dynamically sized array should require a shift of every ...
0
votes
1answer
57 views

Solidity, problem with bytes decoding

back with another question towards solidity Guru's. I am trying to call a method which takes bytes array as an input, but either I am encoding this parameter wrongly or decoding it wrongly. Solidity ...
3
votes
2answers
489 views

Solidity! Invalid implicit conversion from string memory to bytes memory requested

pragma solidity ^0.5 contract ProofOfExistence { // ... some code here function proofFor(string memory document) public view returns(bytes32) { return sha256(document); } //...
2
votes
1answer
36 views

Understanding first evm word of reference types in assembly

Given the following function: function getArrayItems(bytes calldata) external returns ( bytes4 _signature, bytes32 _wutIsThis, bytes32 _length, bytes32 _firstItem ) { assembly { ...
2
votes
2answers
23 views

Validate bytes16 argument size

I have a function which accepts one bytes16 argument. function start( bytes16 reference ) I have some events which I use to track behaviour, using reference as the index. Everything works ...
1
vote
0answers
138 views

How to decode Tx data? Online tool?

Is there a fast way to decode the data returning from a Smart Contract call? I know there are github projects with JS libraries to decode this kind of data (such as https://github.com/ConsenSys/abi-...
2
votes
1answer
546 views

I want to compare hash that I have passed in the argument of the function but keep getting this error

function compare(string memory input, uint _y) public returns (uint){ bytes32 hashedinput = keccak256(input); } Error: Invalid type for argument in function call. Invalid implicit conversion from ...
11
votes
2answers
3k views

What's the difference between 'address' and 'address payable'?

I saw a Solidity smart contract where some variables were declared with the type address and some were declared with the type address payable. What are the differences between the two? Do they store ...
1
vote
1answer
33 views

Solidity, push overrides array [duplicate]

pragma solidity 0.4.24; contract ArraysExample { uint[] numbers; function addUser() public returns (uint[]) { numbers.push(random()); return numbers; } function random() ...
2
votes
1answer
166 views

How to convert string to type defined by an abi.Type for payload construction?

I am writing a CLI in Go that should faciliate users to be able to make contract function calls from it. This entails generating contract ABIs and providing input parameters to the function arguments ...
1
vote
1answer
56 views

Gas cost difference between uint[] and mapping(uint => uint)

When mapping for example a large integer to some integer, uint[] index; index.length = 1000000; index[600001] = 4; is it cheaper to use mapping(uint => uint) index; index[600001] = 4; ? one ...
0
votes
1answer
21 views

Membership in a set of strings

I'm looking solidity help in storing a set of strings and checking for membership in that set. I have a concrete and an abstract question on that: Concrete What is the data structure in solidity ...
1
vote
2answers
59 views

Thinking through from traditional DB to ETH

I am looking for a data structure kind of like this: [ "data": { "id": 0, "hash" : "5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9", "owner" : 0, "status" : "...
1
vote
2answers
1k views

address payable type - store address and send later using Solidity 0.5.0

Solidity 0.5.0 has separated the "address" type into two types: address payable and address. Only address payable have the address.transfer method. I don't want to use the withdrawal mechanism. When ...
0
votes
1answer
51 views

2d array of different types?

I got quite an interesting question. I have created an array of structs, and in each struct, I have an array of address. Then I got a method that when its called on given struct [index] its adds ...
0
votes
1answer
64 views

How to use Ethereum as a database for an order book? [closed]

I hope this question is not too general. I would like to have a few opinions. What is the best way to work with data in Ethereum? Lets say we build a decentralized exchange on a small scale. How ...
0
votes
1answer
55 views

How to implement a data-type Range (or Interval) in Solidity

For a Smart Contract, in Solidity, we want to implement ranges. The reason is that many interactors do so on "ranges". Our Contract holds batches of coupons which we don't need, nor want to, track ...
1
vote
1answer
74 views

Why are timestamps stored in a uint (256 bit) when they would fit in a uint64?

A (signed) 64 bit timestamp can store a date much larger than the age of the universe. On many platforms this would be a micro-optimization, but in the context of Ethereum, we want to squeeze every ...
0
votes
1answer
276 views

true and false not the same as 1 and 0 for web3 / solidity?

When I use remix to execute a function with a bool field and I put 0 into it (which I interpret as false), the remix console output tells me "bool myBool": true (what I don't understand). So I would ...
2
votes
0answers
69 views

Plasma: how were the UTXO bitmaps conceptualised and how will they be stored?

From the white paper, page 5: We construct an interactive game whereby the exiting party attests to a bitmap of participants’ ledger outputs arranged in an UTXO model which requests a ...
1
vote
0answers
63 views

how do you handle token value data type in database?

Ones who do exchange / Investment platforms development, all ERC20 tokens has its atomic unit and only moved by specifying value in its atomic form. for eg: 1 BuritoToken with unit decimals as 18, ...
0
votes
0answers
118 views

Smart Contract - Storing 113+ byte buffer in solidity

So I am using the module (eth-ecies) in npm to perform encryption of a message offchain using the public key of my reciever, and in turn I get a 113+ byte buffer after the encryption is done. Now i ...
4
votes
1answer
2k views

Error: Operator == not compatible with types address and bytes32

How can I change the last line in the following code to make it work? contract University { address public owner; address public student; bytes32 fName; bytes32 lName; ...
1
vote
2answers
172 views

How to type-cast a function pointer in Solidity?

I have a function that takes a parameter of type function (uint256) view returns (uint256). I want to pass it a pointer to a function of type function (uint256) pure returns (uint256). Obviously ...
1
vote
1answer
139 views

Compare memory pointers in Solidity

Is there a way to compare pointers in Solidity? I have two local variables: uint256[] memory a = new uint256[](256); uint256[] memory b = a; If I try a == b I get this compiler error: TypeError: ...
2
votes
1answer
115 views

How much data can be stored in a bytes type in a smart contract?

What are some estimates of how much data can be stored in a bytes type in a smart contract? contract test { bytes data; function storeData(bytes _data) { data = _data; } }
0
votes
2answers
93 views

Stellar operator types compatibility issue

I have an issue creating a calculation based smart contract which performs some calculation based on some formula. Here is the function as bellows: function financialReputation( ufixed xb , ufixed ...
0
votes
2answers
397 views

How to set rate in decimals in solidity?

I want to set my price of token sale in ICO as 1 ether=0.0111111111. Since, solidity doesn't support decimals, what is suggested way to do that?
1
vote
1answer
380 views

Add data to an array in assembly for solidity

Hi I'm trying to make a function in assembly inline with following purpose: Given: An array in the blockchain with names (= bytes32[] _documentHashes). Asked: Find which indexes are equal to the ...
1
vote
1answer
383 views

Recursive struct in solidity

I'm trying to implement a binary tree in solidity. struct BTree{ uint x; BTree lesser; BTree greater; bool nil; } Just realized that this is not possible as struct definition can't be ...
1
vote
1answer
177 views

How do I clone a struct in solidity?

I want to be able to trigger runTest() and return false. I'd need to clone the struct at some point but I'm not sure how to do it in solidity. I thought passing it to another function as memory would ...
1
vote
1answer
207 views

web3.py - Python dtype for contract function with int256[x]

Say I have this example contract: pragma solidity ^0.4.0; contract SEexample { int256[3] thing; uint8 internal i=0; function submit(int256[3] bids,int256[3] prefs) public returns (...
0
votes
1answer
239 views

Is it possible to create structs and declare a variable?

Let's say I have a base struct, Base. I can set it up like this; struct Base{Struct2 data} Here Struct2 is another structure. But what if I want to create a Base struct where the data type value is ...
1
vote
1answer
15 views

Address Not Getting Stored Correctly in State Variable?

I am trying to write a contract where the originator of the contract will offer a reward that can only be claimed by a different address that she or he specifies. To do that, I am trying to create ...
5
votes
2answers
2k views

Convert bytes32 to bytes

Is there a simple way to convert bytes32 to bytes in Solidity? I'm trying to get the length of the string passed in the bytes32 variable but everything gets returned 32 size which makes sense. But ...
0
votes
1answer
154 views

How to check if a function has been assigned?

I want to check if the callback has been assigned to avoid the exception: pragma solidity 0.4.20; contract Test { function() external callback; function test() public { if (/*check here ...
3
votes
1answer
71 views

How to receive a fractional number as parameter to my function?

In my Solidity smart contract, there is a function that needs to receive an amount as parameter. This parameter is the value to be used for a transfer function. Considering the user may need to ...
3
votes
2answers
1k views

Solidity bool size in Structs

I am trying to pack tightly my structure data type. The question that arose is how much storage size does the bool variable take? And if we suppose that it will take 1 byte, if I put consecutive up to ...
3
votes
3answers
411 views

Storage Pattern considering Gas cost

I was following Are there well-solved and simple storage patterns for Solidity? and ended up creating Mapped Structs with Delete-enabled Index to make sure that my array doesn't grow infinitely, when ...
1
vote
2answers
420 views

Serialization of any solidity type

My initial aim was to return structure from the function. After web search I ended up with serialization of data structure into bytes array. Now I try to figure out how each type is represented in ...
2
votes
1answer
380 views

Any way to convert the characters that make up bytes into a string?

For example if I have a bytes4 variable that is "0xabcd1122" is there any way to turn this into a string with a value of "abcd1122"? I am asking because I want to assign a unique identifier to a token ...
1
vote
2answers
454 views

retrieving data from smart contract

I have following Solidity code: pragma solidity ^0.4.18; contract ContractsRegistry { address owner; struct ContractInfo { bytes32 subject; bytes32 companyName; string contactName; ...
0
votes
1answer
1k views

string memory[3] memory is not implicitly convertible to expected type bytes32[] storage ref

I have the following (array of bytes32 types): bytes32[] public allTokenSymbols = ["0x4554480000000000000000000000000000000000000000000000000000000000", "...
4
votes
2answers
93 views

Storing a lot of data in a contract efficiently

Do data types like arrays or maps get stored in the patricia tree (#1)where each element (in the map) has it's own path, and when you add a new element you reference the whole sub tree and add a new ...
1
vote
1answer
68 views

How do types inherit from libraries?

When you're using a library like SafeMath, and then have using SafeMath for uint256; within a contract, how do uints know to become the a parameter of the library functions? Is that just a convention ...
3
votes
2answers
1k views

Why is uint so popular

Among every tutorial/real world example I have yet to come across anyone using the int datatype, I almost thought there wasn't one existing.. Is there a specific reason for uint's uncontested ...
0
votes
1answer
57 views

How do I implement a deque in Solidity?

I have an array of finite size, say something like uint[100] Arr;. My question is, if I want to continually push to this array, what happens if it already has 100 uints in it and I push another one? ...
2
votes
1answer
73 views

Converting 8x8 board game to bytes

I'm trying to save memory by storing a game's 8x8 board as a binary value but am having trouble: Each square on the board can be either 10 (black), 11 (white), or 00 (empty) and there are 64 squares. ...
-1
votes
2answers
293 views

Solidity return type string showing inaccessible

Smart contract pragma solidity ^0.4.11; contract PassData{ PassData passData; string s; function PassData(){ s="come"; } function getData() returns(string){ ...