我试图通过网站上的javascript从我在ganache-cli上创建的合同中调用一个函数。
下面是java脚本的代码:
web3.eth.defaultAccount=web3.eth.accounts[0];
var poe = web3.eth.contract(abi).at('0xc678e3c394db9408503195e506088803eef583b6');
console.log(poe.address);
poe.notarize2(result); 这将导致还原。但是,当我以相同的值直接在块菌中执行相同的函数时,没有任何问题。
以下是合同代码:
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))
}
}
} 发布于 2017-12-13 10:52:51
你增加迁移了吗?
我收到了同样的错误信息,这也是我遇到你问题的原因。然后我意识到我忘记了添加一个迁移,当我这样做时,问题就解决了。希望这能帮上忙。
https://ethereum.stackexchange.com/questions/33211
复制相似问题