Factory contract not working #972
-
Team or ProjectNo response ZK chainEra EnvironmentTestnet L2 block numberNo response zkSolc Version1.5.11 zksync-ethers Version6.15.3 Minimal Reproducible Code or Repo Link function _createPool(address token0, address token1) internal override returns (address pool) {
// // Perform sanity checks.
IERC20(token0).balanceOf(address(this));
IERC20(token1).balanceOf(address(this));
bytes memory deployData = abi.encode(token0, token1);
cachedDeployData = deployData;
// The salt is same with deployment data.
bytes32 salt = keccak256(deployData);
pool = address(new SyncSwapClassicPool()); // this will prevent duplicated pools.
// pool = address(0);
// new SyncSwapClassicPool{salt: salt}();
// // Register the pool. The config is same with deployment data.
// IPoolMaster(master).registerPool(pool, 1, deployData);
console.log("SyncSwapClassicPoolFactory._createPool()");
} Does this work on other EVMs? (If yes, please list at least 1 of them)Yes, eth Sepolia Description of What Your Contract DoesThis is a factory function to deploy a new contract. It breaks with the error Additional DetailsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @bitcoinbrisbane , I'm unable to access the link for the project you've provided: Can I ask you to create a Hardhat/Foundry (or whatever you use) test case that I can reproduce, please, if the project cannot be shared? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi @bitcoinbrisbane , I was able to fork the contracts from the swayswap repo and successfully create a pool with the classic pool factory, so the issue is likely how you are deploying/interacting with the contract. Here is the hardhat script I used: import { ethers } from "hardhat";
// Address of the classic pool factory contract
const CONTRACT_ADDRESS = "0x9Cc1745e2a4E52c438AA2fbD9f0F68728B291dfF";
if (!CONTRACT_ADDRESS)
throw "⛔️ Provide address of the contract to interact with!";
async function main() {
const [signer] = await ethers.getSigners();
const classicPoolFactoryArtifact = await ethers.getContractFactory(
"SyncSwapClassicPoolFactory"
);
const classicPoolFactory = classicPoolFactoryArtifact
.connect(signer)
.attach(CONTRACT_ADDRESS);
const tokenAAddress = "0x04e523d16c59EE86F2955Ba9C78BB1874811C529";
const tokenBAddress = "0x28F93C322aea7681c5cA7DD2F0fc9976C2522DfC";
const testTokens = [tokenAAddress, tokenBAddress];
const data: string = ethers.AbiCoder.defaultAbiCoder().encode(
["address", "address"],
testTokens
);
const poolMasterAddress = "0xdD7870A759Cbe9B755e33ce10Fbc16962c6b44B7";
const masterFactory = await ethers.getContractFactory("SyncSwapPoolMaster");
const master = masterFactory.connect(signer).attach(poolMasterAddress);
await master.createPool(CONTRACT_ADDRESS, data);
const poolAddress: string = await classicPoolFactory.getPool(
tokenAAddress,
tokenBAddress
);
const poolArtifact = await ethers.getContractFactory("SyncSwapClassicPool");
const pool = new ethers.Contract(
poolAddress,
poolArtifact.interface,
ethers.provider
);
console.log("POOL:", pool.target.toString());
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); I recommend using |
Beta Was this translation helpful? Give feedback.
Hi @bitcoinbrisbane , I was able to fork the contracts from the swayswap repo and successfully create a pool with the classic pool factory, so the issue is likely how you are deploying/interacting with the contract.
Here is the hardhat script I used: