Ich habe einen Smart Contract, der ein Byte[64]-Array zurückgibt. In testrpc bekomme ich das richtige Array, aber in Geth bekomme ich ein Array mit allen "0x".
Hier ist der Smart-Contract-Code:
pragma solidity ^0.4.18;
contract DataStore
{
function stringToBytes32(string memory source) returns (bytes32 result) {
assembly {
result := mload(add(source, 32))
}
}
function DataStore()
{
}
function str_to_bytes(string str) constant returns (byte[64]){
bytes memory b = bytes(str);
byte[64] final_str;
for(uint i; i<b.length; i++){
final_str[i] = b[i];
}
return final_str;
}
function getValue() public returns (byte[64])
{
return str_to_bytes("sasdasdasdasdasdasd");
}
}
Die Ausgabe der getValue()
Funktion ist in Geth falsch, aber in TestRPC korrekt.
Irgendeine Idee, warum das passiert?
Ich vermute, dass entweder Ihr Geth-Knoten nicht vollständig synchronisiert ist, Sie auf die falsche Adresse verweisen oder der Vertrag nicht korrekt für das Netzwerk bereitgestellt wird, auf das Geth verweist.
Ich habe den Vertrag für Rinkeby bereitgestellt und wenn ich die getValue- Funktion aufrufe, sehe ich die erwartete Ausgabe:
bytes1[64]: 0x73, 0x61, 0x73, 0x64, 0x61, 0x73, 0x64, 0x61, 0x73, 0x64, 0x61, 0x73, 0x64, 0x61, 0x73, 0x64, 0x61, 0x73, 0x64, 0x0, 0x0.0, 0x0.0 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
Ein Kommentar zum Code, ich schlage vor, dass Sie die Funktion getValue in die Konstante oder Ansicht ändern, um zu verhindern, dass die Transaktion abgebaut werden muss, um die Ausgabe der Funktion anzuzeigen:
function getValue() public view returns (byte[64])
{
return str_to_bytes("sasdasdasdasdasdasd");
}
Wechseln Sie in str_to_bytes
der Funktion byte[64] final_str;
zu byte[64] memory final_str;
und es funktioniert auch in Quorum.
Narayan Prusty
SteveJaxon
Narayan Prusty
Narayan Prusty
Narayan Prusty
VM returned with error err="invalid opcode 0xfd"