Hi guys! How to clone new contract from this on 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++"

Jan 5, 2022, 8:50 AM
two possibilities:
1/ using assembly or yulp (tough)
2/ easy way: using a factory
Cleanedup version
Jan 5, 2022, 10:12 AM
Thx!
Sorry. Contract deployed. But after call deposit() state reverted with error
Jan 5, 2022, 11:51 AM
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
smthing like this:
`
construct () {new ConcatName(abi.encode(‘firstName’);}
Anyone having an issue at this moment, when choosing the compiler version in remixIDE. Seems like stucked to 8.7
Jan 5, 2022, 1:50 PM
yes
Jan 5, 2022, 1:51 PM
Same exact issue
Jan 5, 2022, 1:55 PM
clear cache
Jan 5, 2022, 2:02 PM

© 2024 Draquery.com All rights reserved.