每次我尝试部署一个wei值大于零的程序时,我都会得到以下错误:
代码:
pragma solidity ^0.5.1;
contract testContract {
uint value;
constructor (uint _p) public {
value = _p;
}
function setP(uint _n) payable public {
value = _n;
}
function setNP(uint _n) public {
value = _n;
}
function get () view public returns (uint) {
return value;
}
}输出:
creation of testContract errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.
creation of testContract pending...
0 [vm] from: OxAb8...35cb2 to: testContract.(constructor) value: 1 wei data: 0x608...00001 logs: 0 hash: 0x344...07156
creation of testContract errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.发布于 2020-12-16 04:09:36
也许您需要在智能合约构造函数中为"setP“函数指定一个"payable”说明符。
https://stackoverflow.com/questions/65231260
复制相似问题