Questions tagged [string]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
13 views

String to Bytes Converts to Incorrect Value

I have a string array stored in memory as https://cloudflare-ipfs.com/ipfs/QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s This should convert to ...
0
votes
0answers
5 views

Is there a solidity library with Java StringBuffer like utility?

I am going to be dynamically constructing some JSON. It is a pure view function so dont care about gas cost. Still, it seems lots of string concatenation is very slow, at least in Remix. Maybe some ...
0
votes
0answers
8 views

Only use ASCII strings in solidity?

So I know that strings are UTF8 by default. However, that comes with its set of problems, like taking more storage. Is there a way to only allow ASCII in my contract?
0
votes
0answers
73 views

Recover account from 64-byte string

In October 2015, I generated an account and backed up two things: the address, and a mysterious 64-byte string. I can see the correct balance on the address, so no problem here. I initially assumed ...
0
votes
0answers
56 views

TypeError: Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type string memory

In Remix I'm getting this strange error while calling Strings.sol library: TypeError: Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type string memory. ...
0
votes
0answers
13 views

Invalid string crashes Remix IDE

If I have an empty function that accepts a string memory input, and if I pass invalid strings like: " "a """ the Remix IDE crashes. Is this just an issue with Remix? If not, ...
0
votes
0answers
18 views

Any known hacks by storing string with non-alphanumeric values?

I was checking out hashmasks smart contracts, and they have the following rules for names: No name can be identical There is a limit of 25 symbols (including spaces) Uniqueness is case insensitive (i....
0
votes
1answer
32 views

Solidity: How to represent bytes32 as string

This may be simple in other languages but I can't figure out how to do it in Solidity. I have a bytes32 like this 0x05416460deb76d57af601be17e777b93592d8d4d4a4096c57876a91c84f4a712. I don't want to ...
0
votes
0answers
26 views

Concatenating strings overwriting a variable

I'm building a SC with many strings and concatenations. Is there any way to overwrite a string and, moreover, not using an auxiliary method? Something like: // SPDX-License-Identifier: MIT pragma ...
1
vote
1answer
48 views

How to concatenate an address to a string in solidity

I am trying to find the correct way to concatenate an Ethereum address to a string in Solidity v0.6.7 I tried the following but it did not seem to work : function append(string a, address b) ...
1
vote
0answers
7 views

Check string similarity percentage

How can I efficiently check the similarity of two strings? Or better yet, if I have an array of strings, I want to check that the given string is less than e.g. 80 % similar to any of the other ...
0
votes
0answers
43 views

VM error: invalid opcode. invalid opcode The execution might have thrown

I am trying to take in a 512 character long string and extract the first 312 characters from the string. This is my test on a small scale, tryign to extract 12 characters out from a 30 character long ...
0
votes
2answers
24 views

How to ensure that a string parameter to a function is not empty?

Lets say that I have a function which needs two string parameter , function data(string memory _firstname, string memory _lastname) public { buyer[msg.sender] = Buyer(_firstname, _lastname); } Now, I ...
0
votes
2answers
137 views

how to set a require for a string to not be null

I want to write a require condition for string that string variable could not be null. How to write because string is not taking the != operator function createOrder(address _seller, string memory ...
3
votes
1answer
289 views

Can I use an emoji as part of a string in Solidity?

Can I use an emoji in Solidity?
0
votes
0answers
34 views

String to float maintaining decimal places

I've seen some thread already however I haven't found anywhere a way of converting a string number to float number and maintaining the decimals. ie "27.546" to 27.546
0
votes
0answers
12 views

How can I generate hash of string received from function argument

I want to generate hash of string received through function argument. Sha256 require bytes in argument. How can I convert and then save hash in _hash variable. struct ORGANIZATION{ bytes32 hash; ...
3
votes
1answer
328 views

In solidity, how to copy a string or pass it by value?

In this example I only modify string a, but both a and b are changed. It seems like the string wasn't copied. I only want to change a. How do you copy a string and how do you pass a string by value to ...
3
votes
1answer
339 views

What is the maximum size of string which we can store on solidity?

Is there a limit to the size of a string that we can store on the Ethereum blockchain?
0
votes
0answers
19 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....
2
votes
1answer
298 views

Calling a string variable

Update2: Ismael highlighted that upgrading drizzle and Web3 were crucial. I was using drizzle 1.3 and Web3 1.0. So, using the same Solidity code, I can now read a string array into a webpage, using ...
0
votes
1answer
94 views

How do I order strings in Solidity?

I'm a newbie to smart contract development, and I'm looking to order strings using solidity, I don't care that much what kind of ordering method (alphabetical for example) is used, I just want it to ...
0
votes
0answers
158 views

join an array of strings and map, filter, reduce functions in solidity

I want to concatenate an array of strings into a single string using solidity, just like the array join function in javascript and python. Also I want to do map/filter/reduce functions in an array. Is ...
0
votes
2answers
1k views

Solidity Split Comma-Delimited String into Individual words

Since Solidity functions can't accept String Arrays as arguments, I'm trying instead to pass in a long comma-delimited string, and then convert it to an array of strings on the fly. I'm close - but ...
0
votes
1answer
494 views

How to concatenate uint to address in solidity?

I would like to concatenate an Ethereum address to an uint in Solidity. How can I do that?
1
vote
1answer
142 views

TypeError: Type string calldata slice is not implicitly convertible to expected type string memory

I want to slice a string and save it to a memory or storage variable. Is this possible? function test(string calldata _input) external{ string memory something = _input[1:3]; } I am ...
0
votes
0answers
24 views

Making sure a string (input/output) is less then 64 characters

I'm working though some basic solidity tutorials using remix. I'm having trouble with the concept that there is no way to edit a string built into the language. In other programing languages I would ...
0
votes
0answers
41 views

Splice an Address

So in javascript I can take a string such as yourString[7] and get the 8th character within that string returned to me in string format. I want to take the last character in an Ethereum address, be an ...
0
votes
0answers
27 views

Compare strings

I want to compare two strings but, by using: require(keccak256(abi.encodePacked(_car))==keccak256(abi.encodePacked(car))); I get the following error: InternalCompilerError: Unknown ...
0
votes
1answer
194 views

Convert a string in scientific notation to a number

my smart contract uses an Oracle to retrieve the price. The price is returned as a string in scientific notation, for example, "3e-8". How I can convert this to number (uint)? The token has ...
0
votes
0answers
33 views

Passing a hash value to function

I'm trying to authenticate users by comparing the hashes created by backend server and contract. Seems like "byte32" values cannot be coerced into strings. So, instead I'm converting it into ...
0
votes
1answer
250 views

Explicit type conversion not allowed from "string memory" to "uint256"

I'm using an oracle to get results from a custom api. The result is in string by default. I want to convert it to uint256, so that I can perform basic arithmetic functions. Here's my code: function ...
1
vote
1answer
84 views

In Solidity, Is there any situation, when string is necessary?

In Solidity, Is there any situation, when string is necessary? Please can u explain when I should use string instead of bytes or bytesN? Thanks!
0
votes
0answers
375 views

How can I return string array in solidity?

This is my struct: struct Token { address tokenAddress; uint256 minAmount; bool emergencyUnlock; TokenStatus status; string name; uint256 decimal; string thumbnailUrl; } ...
0
votes
0answers
86 views

Gas-efficient string concatenation

My use-case requires that I feed my contract with a long string (Base64 data), which requires to split it and send it over several transactions so as to not reach gas limit. Then the contract rebuilds ...
0
votes
1answer
70 views

Read and write private variable from child contract

I have a contract MyContract is ERC721. MyContract needs to concatenate a string with an existing token URI using this function: string(abi.encodePacked(_tokenURIs[_tokenId], _URI)); Problem is all ...
1
vote
1answer
27 views

How to save long textual data on blockchain? [closed]

I need to write blogs and save them on blockchain. What are efficient possibilities to store such data on blockchain? Thanks for reading the question, already appreciate your time.
0
votes
1answer
50 views

Where does the length parameter end and the actual string start in an abi encoded string?

Assuming I decided to ABI encode a very long string (for the purpose of this question I just picked an arbitrary 5-paragraph lorem ipsum text generate by https://www.lipsum.com/feed/html) and get out ...
0
votes
1answer
44 views

Why does declaring returns type bytes memory give a compiler error?

If we have the following code: pragma solidity >= 0.5; contract stringsContract { function takesTwo(string memory str, uint idx) public pure returns (bytes memory) { bytes memory ...
1
vote
1answer
65 views

Garbage in string parameters of events

I have an event defined like this: event Created( address indexed target, string indexed name ); I do emit Created(..., _name); // called function with _name = "comment" which gives ...
1
vote
1answer
456 views

Bytes memory as a function parameter increase gas cost

I've a smartcontract compiled with pragma solidity ^0.4.0; version and one function receives a bytes parameters which contain a long string. In these version it doesnt need to set the parameters as "...
0
votes
1answer
291 views

Solidity. Concatenate and hash two strings

Hi all I need tho sha256 two strings. I am new to solidity. This is what I've got: function addressToString(address _addr) public pure returns(string memory) { bytes32 value = bytes32(uint256(...
0
votes
1answer
40 views

Solidity. Concatenate hash w address. TypeError: Operator + not compatible with types string memory and address payable

I am trying to do something simple: examsFinalHash = keccak256(examHash + msg.sender); but I get the following error: TypeError: Operator + not compatible with types string memory and address ...
0
votes
1answer
420 views

What's the proper way to store a long string (like a news article) in Solidity?

I'm working on Layer 2 so gas/efficiency aren't primary concerns, assuming the function can be executed by the EVM
0
votes
1answer
82 views

Storing a monero address in smart contracts?

Assuming I would have to store Monero addresses or any cryptonote based coins addresses in a smart contract, would there be any issues? Consider that those addresses are as long as this random ...
1
vote
1answer
153 views

How to verify the sha256 result of integer 5 in the Zokrates tutorial?

The Zokrates tutorial here starts with calculating the SHA256 hash of (the number) 5. The hex representation of the result is shown at the bottom here: However, I could not reproduce this on my ...
0
votes
1answer
86 views

library modifying string vs string literal

I have a library which has the following function: function strConcat( string memory _a, string memory _b ) internal pure returns (string memory) My contract implements the library ...
1
vote
2answers
229 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 ...
0
votes
1answer
35 views

Can I use string(or any type) list as an argument of an event?

It`s my event. event Transfer(address sender, address receiver, string[] denoms, uint256[] amounts); And I view an Transfer event with watch() function, It`s the result. { address: "...
2
votes
1answer
508 views

Solidity: How to replace specific string position with letter?

I would like to replace a letter at a specific position of a string with another letter. function _stringReplace(string memory _string, uint256 _pos, string memory _letter) internal pure returns (...