Ethereum remix JS VM环境是否与solidity开发的本地环境相同?
我对此有点迷茫,花了几个小时在这上面,但我不知道为什么,基本上我有这个坚固性合同(引诱区块链的第3天)。该代码在remix JS VM环境中工作,但当我尝试构建本地并在带有web3的ganache cli中运行它时,它将部署第一个factory合约,但它不会使用factory createFund函数来创建第二个合约。混音JS虚拟机环境与本地环境有什么不同吗。还是因为我还是新手,所以我错过了什么 下面是我正在玩的代码Ethereum remix JS VM环境是否与solidity开发的本地环境相同?,ethereum,solidity,smartcontracts,remix,Ethereum,Solidity,Smartcontracts,Remix,我对此有点迷茫,花了几个小时在这上面,但我不知道为什么,基本上我有这个坚固性合同(引诱区块链的第3天)。该代码在remix JS VM环境中工作,但当我尝试构建本地并在带有web3的ganache cli中运行它时,它将部署第一个factory合约,但它不会使用factory createFund函数来创建第二个合约。混音JS虚拟机环境与本地环境有什么不同吗。还是因为我还是新手,所以我错过了什么 下面是我正在玩的代码 pragma solidity ^0.4.24; contract test
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);
}
}
“…但它不会使用工厂
createFund
…”。这没有道理。在部署了testFactory
之后,您如何调用createFund
?现在我仍然在使用moca对其运行测试,我正在做的是“wait compiledCampaign.methods.createFund(“Test MN 1”).send({from:accounts[0],gas:'2000000')然后在它上面运行一个断言,看看它是否有地址编辑你的问题来添加测试脚本。您的问题可能就在那里。在这里工作正常似乎您的测试有问题。请添加脚本