首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我在处理事务时得到VM异常:还原?

为什么我在处理事务时得到VM异常:还原?
EN

Ethereum用户
提问于 2017-12-12 20:07:43
回答 1查看 867关注 0票数 1

我试图通过网站上的javascript从我在ganache-cli上创建的合同中调用一个函数。

下面是java脚本的代码:

代码语言:javascript
复制
web3.eth.defaultAccount=web3.eth.accounts[0];
var poe = web3.eth.contract(abi).at('0xc678e3c394db9408503195e506088803eef583b6');
console.log(poe.address);
poe.notarize2(result);  

这将导致还原。但是,当我以相同的值直接在块菌中执行相同的函数时,没有任何问题。

以下是合同代码:

代码语言:javascript
复制
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))
    }
}
}            
EN

回答 1

Ethereum用户

发布于 2017-12-13 10:52:51

你增加迁移了吗?

我收到了同样的错误信息,这也是我遇到你问题的原因。然后我意识到我忘记了添加一个迁移,当我这样做时,问题就解决了。希望这能帮上忙。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/33211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档