布朗尼 - 构造函数序列的长度不正确,预期为 1 但实际为 0
Brownie - Constructor Sequence has incorrect length, expected 1 but got 0
我正在尝试通过 运行ning brownie 运行 scripts/deploy.py --network rinkeby 在 Rinkeby 上部署合约,但出现以下错误:
Constructor Sequence has incorrect length, expected 1 but got 0
我认为问题在于我在 运行 我的 deploy.py 脚本中没有指定构造函数的初始值。这是正确的吗?如果是,我该如何解决?
deploy.py
from brownie import FundMe
from scripts.helpful_script import get_account
def deploy_fund_me():
account = get_account()
fund_me = FundMe.deploy({"from": account})
print(f"Contract deployed to {fund_me.account}")
Solidity 合约
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
...OTHER FUNCTIONS...
}
}
已解决:
尝试使用这个 solidity 代码:
https://github.com/PatrickAlphaC/brownie_fund_me/issues/1
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
constructor() public {
owner = msg.sender;
}
function fund() public payable {
uint256 mimimumUSD = 50 * 10**18;
require(
getConversionRate(msg.value) >= mimimumUSD,
"You need to spend more ETH!"
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(
0x8A753747A1Fa494EC906cE90E9f37563A8AF630e
);
return priceFeed.version();
}
我正在尝试通过 运行ning brownie 运行 scripts/deploy.py --network rinkeby 在 Rinkeby 上部署合约,但出现以下错误:
Constructor Sequence has incorrect length, expected 1 but got 0
我认为问题在于我在 运行 我的 deploy.py 脚本中没有指定构造函数的初始值。这是正确的吗?如果是,我该如何解决?
deploy.py
from brownie import FundMe
from scripts.helpful_script import get_account
def deploy_fund_me():
account = get_account()
fund_me = FundMe.deploy({"from": account})
print(f"Contract deployed to {fund_me.account}")
Solidity 合约
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
...OTHER FUNCTIONS...
}
}
已解决:
尝试使用这个 solidity 代码:
https://github.com/PatrickAlphaC/brownie_fund_me/issues/1
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
constructor() public {
owner = msg.sender;
}
function fund() public payable {
uint256 mimimumUSD = 50 * 10**18;
require(
getConversionRate(msg.value) >= mimimumUSD,
"You need to spend more ETH!"
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(
0x8A753747A1Fa494EC906cE90E9f37563A8AF630e
);
return priceFeed.version();
}