Ok guys and girls what am I missing here. This is all launched on BSC Testnet. I am trying to use the PinkSale token factories for a project that I am working on. I went though and made sure the older OpenZeppelin files where being used. Everything compiles and deploys with no issues.

I thought that I found out what the issue was with the factory. If you look at the token contract that it is cloning. The constructor ends with with assigning the token owner. However the original factory file had the msg.sender being the first thing sent. So I changed that and made it Token Contract v2. I also updated the rest of the code to solidity v0.8

Whenever I go to have the factory contract create a new token it errors out. Before you ask yes I am sending BNB with the transaction.

Sorry I normally dont use pastebin. If it would be easier I could do that for you.

Contracts Deployed On BSC Testnet

Token Factory Manager
0xe38eF21D8B5305DcF578029127cCd05c6eC40e1B

Token To Clone
0xD4B85f3e8df97c604E19e4aa46802f8cdC4F660a

Token Factory
0xA43570c8059D05aE9E42BfC68248e27d7465dFfa

Token Factory V2 (changed the order of argument being passed to the contract)
0x9395fb53eb588469Ef41Bb93A5dbB4D546b226B3

Any and all help would be greatly appreciated.

Jan 26, 2024, 2:59 AM
you're calling initialize on a contract that is not designed as implementation to be cloned
https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable
here's a very simple example
pragma solidity 0.8.23;
import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";

contract myImpl is Initializable {
address public myAddy;
uint public myNumba;

function initialize(uint _myNumba) external initializer {
myAddy = msg.sender;
myNumba = _myNumba;
}

function printMyCode() external view returns(bytes memory) {
return address(this).code;
}
}
contract cloneFactory {
mapping(uint id => address contracts) public spawnedContracts;
uint lastId;
address implAddy;
address owner;

modifier onlyOwner {
require(msg.sender == owner,"no");
_;
}

constructor(address _impl) {
owner = msg.sender;
implAddy = _impl;
}

function createClone(uint num) external {
address newClone = Clones.clone(implAddy);
myImpl(newClone).initialize(num);
spawnedContracts[lastId] = address(newClone);
lastId++;
}
function setImpl(address impl) external onlyOwner {
implAddy = impl;
}
}
paste it into remix and play with it.
Do not use in production, just understand how it works and read the OZ docs before using proxies/clones/anything that keeps the storage separated from the implementation
Jan 26, 2024, 3:46 AM
It is supposed to be one of the token contracts that pinksale uses for its token launcher. The token factory, token manager, and the token itself should all work together. There are something like 5 different token contracts along with their respective factories in the repo.

Thanks for your help though. I am going to read though the docs you posted.
Jan 26, 2024, 3:59 AM
It's not worth to use pinksale factory nor their implementations.
Make yours from scratch and it will be probably better
Add ERC20 to myImpl and you have the base for it
Remember nothing must be hardcoded into implementation's storage, it won't be read once it's cloned as the storage will be on the minimal proxy address
Jan 26, 2024, 4:02 AM
I definitely plan on making everything over from scratch when I have the time. Right now I am working to meet a deadline. I just need to get something working for now since I have to do a small pile of updates to everything as well. So for now I am hoping to work with pinksales files to get this done quicker. Once I have more time I will more then likely go though and rewrite everything.

I am going to read into this more and try to get this figured out soon then later. Maybe I can just update the contracts to use an initialize function?

From what I am understanding I want to make the contract have an initializer function that I will never really call and will be disabled and then have the factory use a separate initialize function (they used OnlyInitialize) that will be used for the cloned contract?
Jan 26, 2024, 4:21 AM
Deadlines are useless if the code doesn't work 😁 take ur time.
Initialize will be called by the factory after the clone is done and he'll be the only one calling it.
The initialize function is in the implementation
If you need ownable, oz have a specific repository for upgradeable contracts.
Even if clones are "immutable" proxies, those still need upgradeable design like normal proxies
Jan 26, 2024, 4:25 AM
That is true bro. Figured Pink has been using these contracts for years so they must work at least lol.

Never tried to clone a contract before but I need to put this token launcher together for this project (there is a lot more to it) and I am hung up on it.

I should of been coding thought he bear market instead of enjoying life and doing other shit lol.
It is strange. I was reading your post on that kraken snipe earlier lol
Jan 26, 2024, 4:31 AM
Nice finding uh😁
Jan 26, 2024, 4:35 AM
Thanks for your help bro. I am going to try to get this figured out. If you know of any good starting point repos I could use please let me know. I have not been coding much and am slow as fuck and updating stuff would be a lot quicker for me. TY again
Jan 26, 2024, 4:38 AM

© 2024 Draquery.com All rights reserved.