remix JS VM环境是否与用于Solidity开发的本地环境相同?

时间:2018-06-20 07:09:18

标签: ethereum solidity smartcontracts remix

我为此花了几个小时,对此有点迷惑,但我不知道为什么,基本上我有这份Solidity合同(吸引区块链的第三天)。该代码可在remix JS VM环境中工作,但是当我尝试构建本地文件并在web3的ganache-cli中运行它时,它将部署第一个工厂合同,但不会使用工厂createFund函数制定第二个合同。是否有某种形式的混音JS VM环境与本地环境不同。还是因为我还是新手而错过了什么?

下面是我正在使用的代码。

pragma solidity ^0.4.24;

contract testFactory{
    address[] public deployedFund;

    function createFund(string NewCampaignName) public{
       address newFund = new testFund(NewCampaignName, msg.sender);
       deployedFund.push(newFund);
    }

    function getDeployedFund() public view returns (address[]){
        return deployedFund;
    }
}

contract testFund {    
    struct OurFunders{
        string FristName;
        address ETHaddress;
        uint128 Amount;
        string Email;
        uint8 Funderpercent;
    }

    OurFunders[] public ourFunders;
    address public manager;
    uint8 public Fpercent;
    bool public IsFunded;
    string public CampaignName;    

     constructor (string NewCampaignName, address creater) public{
        manager = creater;
        CampaignName = NewCampaignName;
    }

    function newFunder(string FristName, address ETHaddress, uint128 Amount, string Email, uint8 Funderpercent) public{
        OurFunders memory newPerson = OurFunders({
            FristName: FristName, 
            ETHaddress: ETHaddress, 
            Amount: Amount, 
            Email: Email, 
            Funderpercent: Funderpercent
        });

        Fpercent = Fpercent + Funderpercent;

        if(Fpercent == 100){
            IsFunded = true;
        }

        ourFunders.push(newPerson);
    }
}

0 个答案:

没有答案