使用WebPack应用程序时,Solidity -EVM无效跳跃



我正在创建基于松露 webpack的前端应用根本没有JavaScript的Udsterand。

该代码可在松露控制台和应用程序上使用,除了函数" append_buy_brent",还将一个新元素添加到名为buy_orderbook_brent

的结构阵列中

坚固:

contract Petroleum{

// Initialisations
address _creator;
uint user_number;

struct Baril_order {
    uint price;
    uint quantity;
    address addr;
}
Baril_order[] buy_orderbook_brent;
mapping(address => uint) account_map;
mapping(uint => uint) user_balance;
mapping(uint => uint) number_of_brent;
function Petroleum() payable{       
    _creator=msg.sender;
    user_number=0;
    test=0;
    account_map[_creator]=0;
    account_map[0x7f8105da4dd1af61da7bf587766103ba8534fcdc]=1;
    user_balance[account_map[msg.sender]]=100000;
    number_of_brent[account_map[msg.sender]]=5;
    number_of_wti[account_map[msg.sender]]=2;
    debt[account_map[msg.sender]]=20;
    user_balance[account_map[0x7f8105da4dd1af61da7bf587766103ba8534fcdc]]=200000;
    number_of_brent[account_map[0x7f8105da4dd1af61da7bf587766103ba8534fcdc]]=7;
    number_of_wti[account_map[0x7f8105da4dd1af61da7bf587766103ba8534fcdc]]=10;
    debt[account_map[0x7f8105da4dd1af61da7bf587766103ba8534fcdc]]=3;
}
function append_buy_brent(uint price, uint quantity, address addr) payable {
        buy_orderbook_brent.push(
            Baril_order({
                price:price,
                quantity: quantity,
                addr: addr,
            })
        );
    }
}

javaScript:

import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'
import Petroleum_artifacts from '../../build/contracts/Petroleum.json'
var Petroleum = contract(Petroleum_artifacts);
var accounts;
var account;
var account1;
window.App = {
start: function() {
    var self = this;
    Petroleum.setProvider(web3.currentProvider);
    web3.eth.getAccounts(function(err, accs) {
      if (err != null) {
        alert("There was an error fetching your accounts.");
        return;
      }
      if (accs.length == 0) {
        alert("Couldn't get any accounts! Make sure your Ethereum client is configured correctly.");
        return;
      }
      accounts = accs;
      account = accounts[0];
      account1 = accounts[1];
      self.refreshBalance1();
      self.refreshBalance2();
    });
  },
append_buy_brent: function(){
        var self = this;
var price_buy_brent= parseInt(document.getElementById("price_buy_brent").value);
        var quantity_buy_brent=parseInt(document.getElementById("quantity_buy_brent").value);
        this.setStatus("Initiating transaction... (please wait)");
        var petro;
        Petroleum.deployed().then(function(instance) {
          petro = instance;
          return petro.append_buy_brent(price_buy_brent,quantity_buy_brent, account, {from: account, value: web3.toWei(1000, "ether")});
        }).then(function(value) {
            self.setStatus("Transaction complete!");
            self.refreshBalance1();
            self.refreshBalance2();
        }).catch(function(e) {
          console.log(e);
          self.setStatus("Error placing buy_brent; see log.");
        });
     },
}

日志:

错误:处理交易时的VM异常:无效跳跃

我希望我第一次提供足够的信息。非常感谢。

它看起来像一个EVM错误。您可以在不将合同部署和功能调用的情况下尝试2个不同的交易中尝试吗?

https://github.com/ethereumjs/testrpc/issues/196

最新更新