Closed vipinkp closed 4 years ago
I have a similar problem, I don't know if it's the same problem or not. I wrote a post also in the Ethereum StackExchange (https://ethereum.stackexchange.com/questions/42927/string-returned-from-mapping-of-struct-array) but with no success, my code should work fine... For every transaction, I store some information in this struct:
struct MoneyTransfer{
address sender;
string comment;
uint creationTime;
uint quantity;
}
struct Transfers {
MoneyTransfer[] structArray;
}
mapping(address => Transfers) private moneyTransferMap;
For each address, the first "comment" string returned by the Java wrapper is this one:
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0004"
Another strange thing: after putting another object in the same array, if the first "comment" string was a long one (80 chars), when I try to get the data with the Java wrapper, I get this error:
java.lang.StringIndexOutOfBoundsException: String index out of range: 1952737052 at java.lang.String.substring(Unknown Source) at org.web3j.abi.TypeDecoder.decodeDynamicBytes(TypeDecoder.java:184) at org.web3j.abi.TypeDecoder.decodeUtf8String(TypeDecoder.java:192) at org.web3j.abi.TypeDecoder.decode(TypeDecoder.java:65) at org.web3j.abi.TypeDecoder.decodeArrayElements(TypeDecoder.java:264) at org.web3j.abi.TypeDecoder.decodeDynamicArray(TypeDecoder.java:244) at org.web3j.abi.FunctionReturnDecoder.build(FunctionReturnDecoder.java:105) at org.web3j.abi.FunctionReturnDecoder.decode(FunctionReturnDecoder.java:42) at org.web3j.tx.Contract.executeCall(Contract.java:178) at org.web3j.tx.Contract.executeCallMultipleValueReturn(Contract.java:214)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@vipinkp is this issue still relevant?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
any update on this?
web3j v 3.3.1 , solidity 0.4.21.
The error java.lang.StringIndexOutOfBoundsException: String index out of range: 4544 occurs when i am returning a byte[] from a function in solidity. i am using ganache-cli and tested the same code with quorum also.