I'm newbie and now in progress for develop some smartcontract use on ethereum private chain.
I have created KeepPolicy.sol for keep policy data to blockchain, and have dapp for call method in KeepPolicy.sol.
The problem is I got error message in response when call the method. The error message is
{ "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}" }
and i have some related code here.
send transaction, call 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;
}
}
The function is payable. Please try to add value argument to your transaction or remove payable from the contract. Eg: .send({ from: admin, gas: 100000, value: 0 })
I close this issue, the problem is about problem when deploy smart contract.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.