首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用wei值部署时出现混音错误

使用wei值部署时出现混音错误
EN

Stack Overflow用户
提问于 2020-12-10 16:51:28
回答 1查看 220关注 0票数 0

每次我尝试部署一个wei值大于零的程序时,我都会得到以下错误:

代码:

代码语言:javascript
复制
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;
    }
}

输出:

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

发布于 2020-12-16 04:09:36

也许您需要在智能合约构造函数中为"setP“函数指定一个"payable”说明符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65231260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档