deposit and retrieve new contract address?
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract ConcatName {
bytes public name;
constructor(bytes memory _name) {
name = _name;
}
function Deposit() external payable returns(address){
return address(new ConcatName(abi.encodePacked(name, abi.encodePacked("+"))));
}
}
I want to get something
contract1.name = "hello"
contract1.deposite() = contract2 //contract2.name = "hello+"
contract1.deposite() = contract3 //contract3.name = "hello+"
contract2.deposite() = contract4 //contract4.name = "hello++"
contract4.deposite() = contract5 //contract5.name = "hello+++"
contract3.deposite() = contract6 //contract6.name = "hello++"
You need to have an address parameter in the constructor that takes the address of the deployed contract factory. Your current code assumes that the contract factory is deployed at msg.sender but that's just your deployer wallet address
nice catch indeed!
1/ you have to deploy the ConcatNameFactory, not the ConcatName 2/ I miss the entrypoint to enter in the loop, so in the factory’s constructor, deploy the very first ConcatContract
Обсуждают сегодня