![](/img/trans.png)
[英]can't deploy contract from web3 to geth node , Error: Transaction has been reverted by the 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.