6.3 Deployment Steps
You will deploy one TokenFactory instance to each chain, and possibly a library if not inlined (though Foundry will inline libraries by default). The Meme Token contracts are deployed by the TokenFactory on the fly, so you do not deploy tokens upfront – only the factory.
Deployment script: If using a Solidity script (for example
DeployTokenFactory.s.sol
), it might look like:
// Pseudo-code for deployment script
contract DeployTokenFactoryScript is Script {
function run() external {
uint256 deployerKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerKey);
// Addresses needed for constructor:
address endpoint = <LayerZero Endpoint for chain>;
address uniFactory = <UniswapV2 Factory address>;
address uniRouter = <UniswapV2 Router address>;
TokenFactory factory = new TokenFactory(endpoint, uniFactory, uniRouter);
console.log("Deployed TokenFactory at:", address(factory));
vm.stopBroadcast();
}
}
You would configure
endpoint
,
uniFactory
, and
uniRouter
for each chain (see Section 7 for the specific addresses on each network).
To deploy on a specific chain network, use Forge with the RPC URL. For example:
-
Ethereum:
forge script DeployTokenFactoryScript --rpc-url $ETH_RPC_URL --broadcast --verify -vvvv -
BSC:
forge script DeployTokenFactoryScript --rpc-url $BSC_RPC_URL --broadcast -vvvv -
and similarly for Avalanche, Arbitrum, Base (with their RPC URLs).
Each execution will deploy the TokenFactory to that chain and print the address. Save these addresses, as you’ll need them to set up the peer mappings.
Alternatively, you can incorporate multi-chain deployment in one script by using Foundry’s broadcast for multiple networks (Foundry allows specifying different chains if configured), but it may be simpler to run the script separately for each chain.
6.4 Post-Deployment Configuration (setPeers)