Ich versuche, eine Funktion aus einem Vertrag aufzurufen, den ich auf Ganache-Cli über ein Javascript auf einer Website erstellt habe.
Hier ist der Code des Java-Skripts:
web3.eth.defaultAccount=web3.eth.accounts[0];
var poe = web3.eth.contract(abi).at('0xc678e3c394db9408503195e506088803eef583b6');
console.log(poe.address);
poe.notarize2(result);
Dies führt zu einem Rückfall. Wenn ich jedoch die gleiche Funktion direkt in Truffle mit den gleichen Werten ausführe, überhaupt kein Problem.
Hier ist der Vertragscode:
contract ProofOfExistence1 {
mapping (bytes32 => bool) private proofs;
// store a proof of existence in the contract state
function storeProof(bytes32 proof) {
proofs[proof] = true;
}
// calculate and store the proof for a document
function notarize(string document) {
var proof = proofFor(document);
storeProof(proof);
}
function notarize2(string document) {
bytes32 doc= stringToBytes32(document);
storeProof(doc);
}
// helper function to get a document's sha256
function proofFor(string document) constant returns (bytes32) {
return sha256(document);
}
// check if a document has been notarized
function checkDocument(string document) constant returns (bool) {
var proof = stringToBytes32(document);
return hasProof(proof);
}
// returns true if proof is stored
function hasProof(bytes32 proof) constant returns(bool) {
return proofs[proof];
}
function stringToBytes32(string memory source) constant returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}
assembly {
result := mload(add(source, 32))
}
}
}
Haben Sie eine Migration hinzugefügt?
Ich habe die gleiche Fehlermeldung erhalten und so bin ich auf Ihre Frage gestoßen. Dann wurde mir klar, dass ich vergessen hatte, eine Migration hinzuzufügen, und als ich das tat, war das Problem behoben. Hoffentlich hilft das.
Ismael
poe.notarize2(result, { gas: 2000000 });
.Johan De Coster
Ismael
build/
Ordner zum Löschen von Artefakten verwechselt, und eine erneute Bereitstellung mittruffle migrate --reset
kann dazu führen, dass es wieder funktioniert. Auch das Arbeiten mit Schnur ist teuer, versuchen Sie es mit einem viel größeren Gaswert 4M, 6M. Was steht auf dem Transaktionsbeleg?