通过元组或Web3.Py中的地址列表部署合同
因此,我正在尝试部署一份智能合约,该合约需要作为其构造函数函数的一部分地址列表。我正在使用部署脚本,并将其传递给十六进制字符串的元组。我已经尝试了字符串,字节组等的列表。 请参阅我的部署脚本:
from brownie import accounts, config, Turtles, network
from web3 import Web3 as web3
def deploy_turtles():
# Grabbing an account from 0th index of Brownie's ganache default wallets
account = get_account()
address1 = web3.toChecksumAddress(0x4A40E425A8D1EE6279F860D8FD5DB3D3661558D6)
address2 = web3.toChecksumAddress(0xA9873C4C5FBD0196D0FBA2E50A3EEE216C4D6780)
addresses = (address1, address2)
turtle_deployed = Turtles.deploy(
"Turtles",
"Turtle",
"ipfs://bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354/",
[100, 10, 20000, 20, 10, 1655480363, 1655473254, 100],
"ea58dfa481a0c08b4af0417e3f62244215a1ab1eae0a100da48407be5cdd94b7",
addresses,
[10, 15],
addresses,
700,
{"from": account},
publish_source=True,
)
在下面,您可以看到我试图部署其相关构造函数的智能合约:
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./ERC721AWithRoyalties.sol";
contract Turtles is Ownable, ERC721AWithRoyalties, Pausable, PaymentSplitter {
string public _baseTokenURI;
bytes32 public _merkleRoot;
uint256 public _price;
uint256 public _presalePrice;
uint256 public _maxSupply;
uint256 public _maxPerAddress;
uint256 public _presaleMaxPerAddress;
uint256 public _publicSaleTime;
uint256 public _preSaleTime;
uint256 public _maxTxPerAddress;
mapping(address => uint256) private _purchases;
event EarlyPurchase(
address indexed addr,
uint256 indexed atPrice,
uint256 indexed count
);
event Purchase(
address indexed addr,
uint256 indexed atPrice,
uint256 indexed count
);
constructor(
string memory name,
string memory symbol,
string memory baseTokenURI, // baseTokenURI - 0
uint256[] memory numericValues, // price - 0, presalePrice - 1, maxSupply - 2, maxPerAddress - 3, presaleMaxPerAddress - 4, publicSaleTime - 5, _preSaleTime - 6, _maxTxPerAddress - 7
bytes32 merkleRoot,
address[] memory payees,
uint256[] memory shares,
address royaltyRecipient,
uint256 royaltyAmount
)
Updated: See error below ->
Running 'scripts/deploy.py::main'...
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/deploy.py", line 48, in main
deploy_turtles()
File "./scripts/deploy.py", line 13, in deploy_turtles
turtle_deployed = Turtles.deploy(
File "brownie/network/contract.py", line 549, in __call__
return tx["from"].deploy(
File "brownie/network/account.py", line 509, in deploy
data = contract.deploy.encode_input(*args)
File "brownie/network/contract.py", line 579, in encode_input
data = format_input(self.abi, args)
File "brownie/convert/normalize.py", line 20, in format_input
raise type(e)(f"{abi['name']} {e}") from None
ValueError: constructor '['0x4a40E425a8D1EE6279f860d8fd5db3D3661558d6', '0xa9873c4c5FBd0196d0fbA2e50a3eEe216C4D6780']' - '['0x4a40E425a8D1EE6279f860d8fd5db3D3661558d6', '0xa9873c4c5FBd0196d0fbA2e50a3eEe216C4D6780']' is not a valid ETH address
So I'm trying to deploy a smart contract which requires as part of its constructor function a list of addresses. I am using the deployment script and passing it a tuple of hexadecimal strings at no avail. I've tried lists of strings, tuples of bytes, etc. If anyone can tell me what data type I need to pass into this smart contract for a list of addresses that would be amazing.
See here my deployment script:
from brownie import accounts, config, Turtles, network
from web3 import Web3 as web3
def deploy_turtles():
# Grabbing an account from 0th index of Brownie's ganache default wallets
account = get_account()
address1 = web3.toChecksumAddress(0x4A40E425A8D1EE6279F860D8FD5DB3D3661558D6)
address2 = web3.toChecksumAddress(0xA9873C4C5FBD0196D0FBA2E50A3EEE216C4D6780)
addresses = (address1, address2)
turtle_deployed = Turtles.deploy(
"Turtles",
"Turtle",
"ipfs://bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354/",
[100, 10, 20000, 20, 10, 1655480363, 1655473254, 100],
"ea58dfa481a0c08b4af0417e3f62244215a1ab1eae0a100da48407be5cdd94b7",
addresses,
[10, 15],
addresses,
700,
{"from": account},
publish_source=True,
)
And below you can see the smart contract I am trying to deploy along with its relevant constructor:
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./ERC721AWithRoyalties.sol";
contract Turtles is Ownable, ERC721AWithRoyalties, Pausable, PaymentSplitter {
string public _baseTokenURI;
bytes32 public _merkleRoot;
uint256 public _price;
uint256 public _presalePrice;
uint256 public _maxSupply;
uint256 public _maxPerAddress;
uint256 public _presaleMaxPerAddress;
uint256 public _publicSaleTime;
uint256 public _preSaleTime;
uint256 public _maxTxPerAddress;
mapping(address => uint256) private _purchases;
event EarlyPurchase(
address indexed addr,
uint256 indexed atPrice,
uint256 indexed count
);
event Purchase(
address indexed addr,
uint256 indexed atPrice,
uint256 indexed count
);
constructor(
string memory name,
string memory symbol,
string memory baseTokenURI, // baseTokenURI - 0
uint256[] memory numericValues, // price - 0, presalePrice - 1, maxSupply - 2, maxPerAddress - 3, presaleMaxPerAddress - 4, publicSaleTime - 5, _preSaleTime - 6, _maxTxPerAddress - 7
bytes32 merkleRoot,
address[] memory payees,
uint256[] memory shares,
address royaltyRecipient,
uint256 royaltyAmount
)
Updated: See error below ->
Running 'scripts/deploy.py::main'...
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/deploy.py", line 48, in main
deploy_turtles()
File "./scripts/deploy.py", line 13, in deploy_turtles
turtle_deployed = Turtles.deploy(
File "brownie/network/contract.py", line 549, in __call__
return tx["from"].deploy(
File "brownie/network/account.py", line 509, in deploy
data = contract.deploy.encode_input(*args)
File "brownie/network/contract.py", line 579, in encode_input
data = format_input(self.abi, args)
File "brownie/convert/normalize.py", line 20, in format_input
raise type(e)(f"{abi['name']} {e}") from None
ValueError: constructor '['0x4a40E425a8D1EE6279f860d8fd5db3D3661558d6', '0xa9873c4c5FBd0196d0fbA2e50a3eEe216C4D6780']' - '['0x4a40E425a8D1EE6279f860d8fd5db3D3661558d6', '0xa9873c4c5FBd0196d0fbA2e50a3eEe216C4D6780']' is not a valid ETH address
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UR地址需要采用校验和格式。
执行此操作:
编辑:
最后一个地址输入需要是一个地址,而不是地址列表
Ur addresses needs to be in a checkSum format.
Do this:
EDIT:
The last addresses input need to be a single address, not a list of addresses