简体   繁体   English

SOLIDITY REMIX 编译器,在部署我的合约后收到此错误(无效的 BigNumber 字符串)

[英]SOLIDITY REMIX compiler, after deploying my contract getting this ERROR (Invalid BigNumber string)

I'm working on my Udemy course project.. the problem with this course is that been used old version solidity 0.4.17.. I'm trying to update this project to a current version... after updating the code and tried to compile on Remix compiler... it compiles with no any errors or warnings on the specific lines, but when I try to deploy a contract on remix:我正在研究我的 Udemy 课程项目..这门课程的问题是使用了旧版本的solidity 0.4.17 ..我正在尝试将这个项目更新到当前版本......在更新代码并尝试之后在 Remix 编译器上编译...它在特定行上编译时没有任何错误或警告,但是当我尝试在 remix 上部署合同时:

it shows:表明:

creation of Campaign errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.1.1)创建活动出错:编码 arguments 时出错:错误:无效的 BigNumber 字符串(argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.1.1)

so I don't really understand what is the problem here?所以我真的不明白这里有什么问题?

this is my solidity contract code:这是我的solidity合约代码:

// SPDX-License-Identifier: GPL-3.0

pragma solidity >0.4.17 <0.8.0;实用性 >0.4.17 <0.8.0;

contract CampaignFactory {合同 CampaignFactory {

address[] public deployedCampaigns;

function createCampaign(uint minimum) public {
    address newCampaign = address ( new Campaign(minimum, msg.sender));
    deployedCampaigns.push(newCampaign);
}

function getDeployedCampaigns() public view returns (address[] memory) {
    return deployedCampaigns;
}

} }

contract Campaign {合同活动{

struct Request {
    string description;
    uint value;
    address recipient;
    bool complete;
    uint approvalCount;
    mapping(address => bool) approvals;
}

Request[] public requests;
address public manager;

uint public minimumContribution;

mapping(address => bool) public approvers;

uint public approversCount;

modifier restricted() {
    require(msg.sender == manager);
    _;
}

constructor(uint minimum, address creator){
    
    manager = creator;
    minimumContribution = minimum;
}

function contribute() public payable {
    require(msg.value > minimumContribution);
    
    approvers[msg.sender] = true;
    approversCount++;
}

uint numRequest;


function creatRequest(string memory description, uint value, address recipient) public restricted {
            
    Request storage newRequest = requests[numRequest++];
       newRequest.description = description;
       newRequest.value = value;
       newRequest.recipient = recipient;
       newRequest.complete = false;
       newRequest.approvalCount = 0;
    
}

function approveRequest(uint index) public {
    Request storage request = requests[index];
    require(approvers[msg.sender]);
    require(!request.approvals[msg.sender]);
    
    request.approvals[msg.sender] = true;
    request.approvalCount++;
}


function finalizeRequest(uint index) public restricted {
    Request storage request = requests[index];
    
    require(request.approvalCount > (approversCount / 2));
    require(!request.complete);
    
    payable(request.recipient).transfer(request.value);
    request.complete = true;
}

} }

thank you in advance for taking your time to look at this problem...提前感谢您抽出宝贵时间来研究这个问题......

EDIT:编辑:

Ok I manager to pass this error, but now when I try to create my request I get an error:好的,我经理传递了这个错误,但是现在当我尝试创建我的请求时,我收到一个错误:

[vm] from: 0x5B3...eddC4to: Campaign.creatRequest(string,uint256,address) 0x7b9...b6AcEvalue: 0 weidata: 0x83e...00000logs: 0hash: 0x8d9...a5ccb transact to Campaign.creatRequest errored: VM error: invalid opcode. [vm] 来自:0x5B3...eddC4to:Campaign.creatRequest(string,uint256,address) 0x7b9...b6AcEvalue:0 weidata:0x83e...00000logs:0hash:0x8d9...a5ccb 交易到 Campaign.creatRequest 错误: VM 错误:操作码无效。 invalid opcode The execution might have thrown.无效的操作码 执行可能已经抛出。 Debug the transaction to get more information.调试事务以获取更多信息。

so the steps I do:所以我做的步骤:

  1. set my minimum contribution to "0" and add a creator address "0x0ABC"将我的最低贡献设置为“0”并添加创建者地址“0x0ABC”

  2. I contribute 1 Ether with same address "0x0ABC"我贡献了 1 个具有相同地址“0x0ABC”的以太币

  3. and I pick a random different address from the remix copy and paste into my "createRequest" I add string "string" amount "uint" address "0x0CCC"我从混音副本中选择一个随机不同的地址并粘贴到我的“createRequest”中我添加字符串“string”数量“uint”地址“0x0CCC”

and when I click createRequest I get this error I stated above;当我单击 createRequest 时,我收到上面提到的这个错误;

在此处输入图像描述

在此处输入图像描述

Solidity currently (v0.8) doesn't allow writing a "struct containing a mapping" into a storage array . Solidity 当前(v0.8)不允许将“包含映射的结构”写入存储数组 But you can write it into a mapping .但是你可以把它写成一个映射

mapping (uint => Request) public requests;  // changed to mapping

instead of代替

Request[] public requests;  // original code

You'll lose the ability to retrieve the array length.您将失去检索数组长度的能力。 But you're already keeping it in the numRequest variable, so it's all good.但是您已经将它保存在numRequest变量中,所以一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Solidity 智能合约代码中的预期未知错误 - Remix - Solidity Expected unidentified error in smart contract code - Remix 部署到Azure后的编译器错误 - Compiler error after deploying to Azure 正在获取编译器错误(无效的标识符) - getting compiler error (invalid identifier) Solidity:抽象合约并覆盖 VRFConsumerBase 编译器/版本/导入问题 - Solidity: Abstract contract and override VRFConsumerBase compiler/version/import issues 不稳定的混音编译器错误“编译期间未知异常” - Unstable remix compiler error “Unknown exception during compilation” 为什么我的代码在 remix 上显示 pragma 错误? - Why my code showing pragma error on remix? 类型错误:“发送”和“转移”仅适用于“地址应付”类型的对象,而不是“地址”类型的对象。 在 remix ide 上编译合同时出错 - TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address". Error on compiling contract on remix ide solidity: 错误信息 源文件需要不同的编译器版本 - solidity : error information Source file requires different compiler version 在Qt中切换编译器后出现错误 - After switching compiler in qt I'm getting error Solidity 和 truffle 的编译器问题 - compiler problem with solidity and truffle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM