簡體   English   中英

Eth 私有鏈向智能合約發送交易錯誤“交易已被 EVM 還原”

[英]Eth private chain sent transaction to smartcontract error "Transaction has been reverted by the EVM"

我是新手,現在正在開發一些在以太坊私有鏈上使用的智能合約。

我創建了 KeepPolicy.sol 用於將策略數據保存到區塊鏈,並在 KeepPolicy.sol 中為調用方法創建了 dapp。

問題是我在調用該方法時收到錯誤消息作為響應。 錯誤信息是

{ "message": "Transaction has been reverted by the EVM:\n{\n "blockHash": "0x11378a4cdaa39bf77b68d8a522d6f337eb897182f6110844e4b6b0b6ea14ef54",\n "blockNumber": 4349,\n "contractAddress": null,\n "cumulativeGasUsed": 23144 ,\n "effectiveGasPrice": 0,\n "from": "0x2013291683023bae332f1e47d378f50265c3d88e",\n "gasUsed": 23144,\n "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",\n "status": false,\n "to" : "0xd16ea25805abf4e6defad30e6669fe68dd176aed",\n "transactionHash": "0xaab5b843ba14d2 a4ff63a1a91e64f4fed7bbbdee8c7f13870d2f6132155f8d4a",\n "transactionIndex": 0,\n "type": "0x0",\n "events": {}\n}" }

我在這里有一些相關的代碼。

發送交易,調用 setPolicy

return new Promise(function (resolve, reject) {
    contract.methods.setPolicy(hashId, hashHospitalString, encHospitalString, encPub).send({ from: admin, gas: 100000 })
    .then(function (receipt) {
        if (receipt) {
            console.log('transaction receipt', receipt)
            resolve(receipt)
        }
        resolve({result: false})
    }).catch(function (err) {
        return reject(err)
    })
})

KeepPolicy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

contract KeepPolicy {

    struct Policy {
        string hashId;
        string hashHospitalString;
        string encHospitalString;
        string encPub;
    }

    uint256 countId;
    mapping (uint256 => Policy) public policies;

    receive() external payable {}

    function setPolicy(string memory _hashId, string memory _hashHospitalString, string memory _encHospitalString, string memory _encPub)
    external payable {
        uint256 count = countId++;
        policies[count].hashId = _hashId;
        policies[count].hashHospitalString = _hashHospitalString;
        policies[count].encHospitalString = _encHospitalString;
        policies[count].encPub = _encPub;
    }
}

function 是應付的。 請嘗試為您的交易添加價值參數或從合同中刪除應付賬款。 例如: .send({ from: admin, gas: 100000, value: 0 })

我關閉了這個問題,問題是關於部署智能合約時的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM