4
  1. I send the transaction from my javascript
  2. Metamask open the transfer-dialog
  3. i confirm

    i get an error message in metamask (inpage.js:1 MetaMask - RPC Error: Error: Error: [ethjs-rpc] rpc error with payload {"id":3801695059583,"jsonrpc":"2.0","params":["0xf8ac098504a817c80082753094bd212f85764be5ecdb5d0ca44ed46ac866b352c781c8b844d0679d3400000000000000000000000058f9015d8b36eacbd4d105cb79872992c073583f0000000000000000000000000000000000000000000000000000000000000000822d45a028d2355a1149fac93070742fc4e14213f441d4a8dfd97611b4de238f1ef70ffaa048f0eed65a9c495ce42229d569d156a7ff4cc206efced1f25e1c779c53f24485"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: revert )

i reset the transaction history for the account in metamask-setting

**Information about the accounts in my html ************************* Coin: (obj/adr/data):[object Object]/0xBd212f85764Be5ecDB5d0ca44ed46AC866B352c7/undefined CoinContract: (obj/adr/data):[object Object]/undefined/undefined Coin anzeigen Minter: 0x6d8c98f8eb01f8f7ee55d25bf01e30fa64333940 Coin erzeugen Account1 0x6d8C98f8eb01F8f7ee55D25Bf01e30Fa64333940 Saldo1 65764158165999998600 Amount: 0.37 Coin senden Account2 0x58f9015d8B36EAcBD4d105CB79872992C073583F Saldo2 30997031680000000000 Amount: 0.37 Coin senden Account3 0xBd212f85764Be5ecDB5d0ca44ed46AC866B352c7 Saldo3 0 Amount: 0.37


************Calling the transaktion from container.js**************

function CoinSenden (data,adressat) {

console.log("Coin senden: " + adressat);

try {

//
// Code für ändern ????
//
var param1=data.amount;
var myContract = web3.eth.contract(CoinABI);
var myContractInstance = myContract.at(CoinContractADR);
console.log("contract/contractinstanz:" + myContract + "/" + myContractInstance);
console.log("contract/contractinstanz:" + myContract.address + "/" + myContractInstance.address);
console.log("para:" + param1 + "/" + "adr:" + ContainerAccount2);

myContractInstance.send(
  ContainerAccount2,param1,
  {from : ContainerAccount2, value: 200, gas: 30000, gasPriceInWei : 1000}, 
  function(err, myContract){
    if(!err) {
       // NOTE: The callback will fire twice!
       // Once the contract has the transactionHash property set and once its deployed on an address.
        // e.g. check tx hash on the first call (transaction send)
       if(!myContract.address) {
           console.log("Phase1- " + myContract.transactionHash) // The hash of the transaction, which deploys the contract

       // check address on the second call (contract deployed)
       } else {
           console.log("Phase2- " + myContract.address) // the contract address
       }
        // Note that the returned "myContractReturned" === "myContract",
       // so the returned "myContractReturned" object will also get the address set.
    }
    else {

      console.log("Fehler in der Methode beim Coin senden: " + err);

    }
  });



console.log("Coin senden fertig.")

} catch (err) {

console.log("Fehler beim Coin senden: " + err);

}

}

well, not to much. I want to see that it is working : 1. the committed transaction in ganache 2. the new balance for the accounts

4

5 回答 5

3

是的,我也有同样的问题。但对我来说答案很简单。我只需要清除 Metamask 中的交易历史。设置 -> 重置帐户。在此处输入图像描述. 原因是 Metamask 在内部保存状态,跟踪本地区块链的 nonce。当您重置本地区块链但重置 Metamask 时,它会感到困惑,并认为它正在尝试为过去的区块发送交易。但是重置帐户会清除该历史记录,所以你很高兴。它不会改变余额,因此超级快速和简单。

于 2020-08-25T00:52:11.810 回答
2

我遇到了这个问题,终于解决了。

当您在 Metamask 上从一个 Ganache 帐户更改为另一个帐户时,问题是刷新问题。如果您没有在 App.js 中进行相应的代码刷新,您将在某处出现导致此错误的空值。

在我的情况下,对于一个购买和销售物品的 DApp,在连接到 MetaMask 上的 ganache 帐户 0(coinbase 帐户)时成功出售物品后,我出售该物品,然后切换到 Ganache 帐户 1(或任何其他 ganache 帐户)到购买刚刚出售的物品。现在我一直收到这个错误,这很糟糕。在检查我的代码时,我发现了来自帐户:App.account 默认指向 0x0 并且在 Metamask 上更改 Ganache 帐户后可能没有刷新(即使您在浏览器上物理刷新),您需要确保有代码刷新以重新加载项目。因此,您需要重新运行 displayAccount 函数以刷新 App.account 并确保它不为空,这解决了问题:请参阅我的代码:

 App.displayAccountInfo(); //I added this line before the buyItem method could work  
    const transactionReceipt = await itemStoreInstance.buyItem(
        _itemId, {
            from: App.account,// This was null till i added displayAccountInfo() above
            value: _price,
            gas: 5000000
        }
    ).on("transactionHash", hash => {
        console.log("transaction hash", hash);
    });

在您在 Metamask 上更改为不同的 Ganache 帐户并将其分配给 App.account 后,显示帐户会简单地调用 eth.getAccounts:见下文:

displayAccountInfo: async () => {
    const accounts = await window.web3.eth.getAccounts();
    App.account = accounts[0];
    $('#account').text(App.account);
    const balance = await window.web3.eth.getBalance(App.account);
    $('#accountBalance').text(window.web3.utils.fromWei(balance, "ether") + " ETH");
},

将此应用于您的问题的上下文,查找 null 的位置,它将解决问题

于 2020-05-20T14:24:37.680 回答
0

这是一个非常小的问题,我确实犯了和你一样的错误。但我想通了

改变这个

{from : ContainerAccount2, value: 200, gas: 30000, gasPriceInWei : 1000} 

{from : ContainerAccount2, value: web3.utils.toWei( (200).toString() , 'ether'), gas: 30000, gasPriceInWei : 1000}

那么你的问题就迎刃而解了。

解释:您不能像以前那样直接发送以太币,只需转换为“单位

希望你明白我的意思

于 2020-11-03T10:39:21.923 回答
0

当在(本地节点)Metamask上使用 RPC 连接到测试网络时,也会发生 rpc-payload 的此错误。localhost将发生与通过 HTTP 服务 RPC 的机器上的 geth 相同的传输块。

在此处输入图像描述

如果您连接到网络上的另一个 RPC 服务节点,限制就会消失。

在此处输入图像描述

于 2020-08-08T09:59:51.050 回答
0

答案可能为时已晚。但只是为了其他进来的人。我今天遇到了同样的问题。后来修好了。这是由于在 javascript 中创建合约实例的方式不正确。请检查合约实例的创建方式。好吧,这可能只是其中一种情况!

于 2019-08-16T23:37:20.890 回答