Questions tagged [string]

The tag has no usage guidance.

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

What is the most efficient way to parse a string of integers to an array?

I perform an Oraclize query on an XML file, and receive this string in return: ["31", "25", "24"] What would be the most efficient way to parse through this string and store the numbers into a uint8 ...
1
vote
1answer
222 views

Vyper and strings

How can I manipulate strings in Vyper? In solidity I could use Nick Johnson's string library. He's using assembly to do that. But that's not possible with Vyper as far as I know.
0
votes
0answers
110 views

Dynamically-sized byte array is value type?

In the doc, it says bytes: Dynamically-sized byte array, see Arrays. Not a value-type! string: Dynamically-sized UTF-8-encoded string, see Arrays. Not a value-type! Not a value-type! If ...
1
vote
2answers
1k views

How to convert/decode Solidity bytes32 to Python string via web3.py

Inside a Solidity contract, I have this variable: zBytes32 = "HelloBytes32"; after Python web3.py retrieving that variable, zbytes32 = contractInstance.functions.getzBytes32().call() print(...
0
votes
1answer
98 views

How to handle structs within solidity any

What's the possible workaround for passing an array of strings (not supported by solidity at current time). I am using an array of struct that is state variable to a contract. pragma solidity ^0.4.23;...
0
votes
2answers
1k views

How to store hash of an Excel file in Blockchain? [closed]

I'm sorry if this question does not seem to be logic. I want to store hash of an Excel file in Blockchain by following function : //byte fileHash; event LogsetFileHash(byte _hashValue); ...
1
vote
1answer
215 views

Alternative for String type in smart contract and Solidity?

Regarding the fact using String in contract is expensive, is there any alternative type in Solidity ? The input value (Payload) I want to set is as follows : {"SQN":4,"Node_ID":"...
0
votes
1answer
260 views

Read String as bytes (Oraclize callback)

I have an Oraclize call that returns the following (a string): "00000000000000000000000000000000000000000000000000000000000003e8" Now this is 1000 (bytes32 hex) You can check here: https://www....
1
vote
1answer
63 views

(Solidity) Is using 'string' safe?

Maybe stupid question, but just want to be sure before deploying contract on main net. In my contract user can change his name(:string) to whatever he likes. Is it totally safe? I mean, is here some ...
0
votes
1answer
66 views

What's the best way of searching in a mapping of objects? [duplicate]

I need a mapping of objects like this: mapping (string => person) as clients; struct person{ string name; uint score; } let's say i have 3 persons on my table: john doe marcus ...
2
votes
2answers
3k views

Does Solidity support passing an array of strings to a contract's constructor yet?

I am going through a tutorial from 2017 that says it was updated in January of 2018. It says that currently you can not pass an array of strings directly to the constructor of a contract and that you ...
0
votes
0answers
328 views

Send request failed { code: -32602, message: 'invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Hash' }

I am new to ethereum and deploying my first contract with simple method getting following error: [2018-03-24 11:08:14.364] [ERROR] ipcProviderBackend - Send request failed { code: -32602, message: '...
1
vote
0answers
275 views

String returned from mapping of struct array

I want to store some details from every transaction. These are the struct and the variable: struct MoneyTransfer{ address sender; string comment; uint creationTime; uint quantity; } ...
0
votes
1answer
326 views

How long can a string be until it spills into the next word?

string is dynamic length storage. I imagine a string of length (bytes length) 1, 2 or 3 is all the same length on storage, probably one word. Which byte causes it to spill over into a second, third ...
0
votes
1answer
411 views

Issues with converting UINT to STRING - strange character [duplicate]

I am trying to use the uintToString method to convert a uint to string but I keep getting a weird square character in front of the resulting string. How do I remove this character, or better yet how ...
3
votes
1answer
3k views

Solidity convert hex string to bytes

I try to convert hex string to bytes. function MyContract() public { string memory str = "A76A95918C39eE40d4a43CFAF19C35050E32E271"; array1 = bytes(str); bytes memory str1 = hex"...
1
vote
1answer
228 views

string-float convertation to uint

Hi guys, i need help! Trying to make a func that converts string-presented float with 2 dec to uint * 00 etc. if _s = "970452.22" result must be "97045222" but i do something wrong (when i try to ...
0
votes
1answer
243 views

How to take a string with variable length decimal places, and convert it to a whole number uint?

I'm experimenting with writing an ethereum-usd price ticker taking data from the coinmarketcap API using Oraclize's API. I noticed that Oraclize has a function called parseInt that can be used to ...
1
vote
0answers
151 views

Convert an hexadecimal string to bytes in pure Solidity

I am using Oraclize to recover a signature from a website. When I have it, I have to check if the address who signed it is correct. To do that, I would use ECRecovery from Zeppelin. The signature ...
3
votes
1answer
431 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
1answer
2k views

How to store strings in an array in solidity?

I am trying to build a simple application on ethereum where strings can be added/deleted from an array and the contents of this array can be shown in a frontend UI. The basic structure of the smart ...
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", "...
2
votes
1answer
371 views

How to copy a string field from one contract to another?

I want one contract to be able to copy fields from another. contract Klendathu { string public bugs; function Klendathu(string _bugs) public { bugs = _bugs; } } contract RogerYoung { ...
1
vote
3answers
752 views

Compare last 2 digits of block hash

I am having trouble doing some string comparison against the last 2 digits of a block hash in solidity. I'm also a little bit confused about how to work with a single character, as it appears that a ...
3
votes
1answer
792 views

Simplest way to use a variable in an Oraclize query?

I have a variable number in my Solidity contract which changes and I need to incorporate this into an oraclize query. My oraclize query looks like the following: oraclize_query(60, "URL", "json(https:...
0
votes
1answer
2k views

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

A Smart Contract needs to check the uniqueness of a number inside a serie. The serie is specified by a string, and the number by a uint256 type. Is there any easy way on Solidity to compute a hash ...
2
votes
2answers
823 views

What is best what to store a string's compressed version on a smart-contract?

Storing string is expensive on smart-contracts and charge us expensive fees even if we want to store them in Events. Instead I want to store each string's decoded version in a smart-contract in order ...
0
votes
2answers
563 views

Events with string argument not working (not indexed)

I am trying to listen to an event on rinkeby test which I run locally. Every thing works fine when my argument is int such as event EventTester(int values); When I change the event argument to string ...
2
votes
0answers
476 views

Can I store data in an ERC20 token?

Can i store data, e.g. a string inside a token? If so, this data will follow the token around if I transfer it to someones wallet?
0
votes
2answers
2k views

Declare string inside function

I tried to declare string inside my function but it doesn't work. How to declare string inside function?
2
votes
2answers
1k views

How to put a variable inside a string in solidity

Does anyone know how to do this, I want to put a variable inside a string: currently using: oraclizeID = oraclize_query("URL","json(https://opensky-network.org/api/states/all?icao24=a4dad4).states[...
3
votes
2answers
454 views

Convertion from bytes 8,16,32 to String

I know it has been asked a lot of times but the newest post about this I could find was about 1 year old. To me it seems quite possible that things have changed since then. So my question: Is there an ...
0
votes
1answer
600 views

Solidity string slice error

I am using a string utility library for Solidity with the aim of splitting a string on a specific delimiter. I followed the instructions from the library: var s = someString.toSlice(); var foo = s....
1
vote
1answer
92 views

How to download array of strings

EOS requires token holders to generate public keys and register them, by using their "register" function in their smart contract. Here's the function (copied from Etherscan): mapping (address => ...
6
votes
1answer
1k views

How to store and load an IPFS hash as bytes32 in contract written in Solidity [duplicate]

An IPFS hash can be expressed in hexadecimal which is 34 bytes long. Afaik it is most efficient to store fixed length values in a Ethereum contract, thus a maximum of 32 bytes (bytes32). Because the ...
1
vote
1answer
45 views

Dealing with mapping(string => string[])

I have a contract with different categories. We can assume them to be the following here: Cities Countries Counties Suppose I want to add a new city to the category cities. I'm assuming this has to ...
0
votes
2answers
561 views

Why is string getter returning an empty response?

This is a sequence of another question I asked. I have the following contract contract User { string publicKey; function setPublicKey(string _publicKey) onlyOwner { ...
-1
votes
2answers
302 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){ ...
3
votes
1answer
4k views

Ethereum Address string size

Question: How many (or up to how many) characters does a Ethereum address have? Elaborating: I have been looking online for an answer but it seemed harder to find than I expected. I am working on ...
2
votes
2answers
234 views

Wrong order when calling a function to return a string

I have an array of strings in my Contract.sol: string[] messages; function getMessage(uint i) constant returns (string) { require(messages.length > i); return messages[i]; } In my app....
3
votes
1answer
2k views

How to return string over 32 characters from bytes32[] array?

I have a bytes32[] array. I convert strings to bytes32 before they are added to the array as follows: function stringToBytes32(string memory source) returns (bytes32 result) { assembly { ...
2
votes
1answer
230 views

Parsing contract endpoint output

A contract endpoint on Ropsten returns a set like this: (uint256 _assetId, address _assetOwner, address _issuer, string _content, uint256 _sellPrice, uint256 _status) The endpoint is getAssetById at ...
17
votes
1answer
1k views

The Unicorn Mystery - Solidity fails to decode valid UTF-8 encoded bytes

The Ethereum Foundation has the Unicorn token to encourage donations, and the unicorn emoji is represented by three bytes. How in the world did they do that? I know that Solidity supports unicode ...
3
votes
1answer
2k views

Is there a limit on no of the parameters that can be passed to a function? [duplicate]

I have created a smart contract function in ethereum. I am unable to use more than four parameters to the function. If a I create a function with more than 4 parameters and call the it by passing ...
3
votes
0answers
220 views

Checking if an address is encoded on the end of a bytes array

I have a bytes array. Within the last 20 bytes, there is an address stored. I am trying to compare the address at the end of this array to the address of a msg.sender, and am wondering if there is a ...
2
votes
2answers
556 views

Using strings as indices in Solidity

Can I use strings as identifiers in a Solidity mapping? I want something like this: contract C { mapping(string => mapping(address => uint)) public balances; string[] public tokennames;...
5
votes
2answers
1k views

Array of Strings in Solidity

I am storing addresses on the blockchain for IPFS objects, and the addresses are more than 32 bytes. I was using bytes32 for testing but I have truncation. I am seeking a method to read data from the ...
9
votes
3answers
8k views

Is it possible to check string variable's length inside the contract?

I want to sent a string as an argument to a function. But some user may enter maybe 100 size string or even larger. [Q] Inside the function is it possible to check the size of the string and return ...
1
vote
1answer
372 views

How to build an address book for Ethereum addresses?

I would like a simple address book referencing a user name to an ethereum address like, mapping (string => address) addressOf; Unfortunately I can't access that mapping as a public call, as ...
1
vote
1answer
673 views

Empty string value returned when returns variable is not named in declaration

I'm trying to implement a simple "pop" function in solidity, and I am getting very different behaviour with string values depending on whether or not I name the returns value in the function ...