Flaunching a Coin
Launching a token should comprise of three steps. Firstly we will need to upload a coin image to IPFS, followed by uploading the token metadata to IPFS. Once we have our data available, we can make the onchain call to flaunch the token.
1. Upload image
When uploading an image, it is recommended to use jpg
, png
, webp
or gif
. These can be uploaded directly to an IPFS protocol such as Pinata either through their SDK or through their manual control panel.
Once the image is uploaded, you will need to note the CID
, also sometimes known as the IPFS Hash
, for the next step.
2. Upload JSON metadata
With our image, we will now need to upload a JSON metadata structure to IPFS that defines some additional information about the coin. This metadata is picked up by the frontend to provide information about social networks linked to the coin, as well as a human readable description.
{
"name": "Token Name",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc efficitur ut orci.",
"image": "ipfs://ImageCID",
"external_link": "https://flaunch.gg",
"discordUrl": "https://discord.gg/flaunchgg",
"twitterUrl": "https://x.com/flaunchgg",
"telegramUrl": "https://t.me/flaunchgg",
"collaborators": []
}
Again, take note of the CID
(IPFS Hash
) of the uploaded JSON metadata for step 3.
3. Create the onchain call data
When flaunching a coin we can make a call directly to the PositionManager contract, but it is recommended to use the FlaunchPremineZap which adds additional logic and functionality on top of the default function call.
As you can likely garner from the name of the zap, it allows the caller to premine their own token before other users can frontrun it. If this logic is not required, then you can call PositionManager directly with the same parameters instead and save a small amount of gas.
/**
* Parameters required when flaunching a new token.
*/
struct FlaunchParams {
string name;
string symbol;
string tokenUri;
uint initialTokenFairLaunch;
uint premineAmount;
address creator;
uint24 creatorFeeAllocation;
uint flaunchAt;
bytes initialPriceParams;
bytes feeCalculatorParams;
}
Below is a breakdown of each parameter that is passed, as well as some additional detail in constructing them and examples where applicable.
4. Determine the flaunching fee
There are two function calls that should be made to determine the ETH fee that will be required to flaunch the token. There is a flaunching fee that is 0.1% of the market cap set, and any token premine costs. The latter is optional, but the first will always be required.
Find the Flaunching fee
Firstly, the 0.1% of the market cap value can be retrieved by passing the initialPriceParams
attribute from the FlaunchParams to get back an ETH value.
uint flaunchingFee = PositionManager.getFlaunchingFee(
FlaunchParams.initialPriceParams
)
Find the Premine fee
Passing the number of tokens that you are wanting to purchase, as well as the initialPriceParams
we can calculate the cost to premine the tokens. We can provide slippage here, though it shouldn't be required as it will only fall within the fair launch amount.
uint premineFee = FlaunchPremineZap.calculateFee(
FlaunchParams.premineAmount,
0, // The slippage percentage with 2 decimal places
FlaunchParams.initialPriceParams
)
Note: This can be overpaid and the sender will receive a refund afterwards of unspent ETH.
5. Flaunch!
Now that we have our fees and combined parameters we can make our call to flaunch our token!
(address memecoin, uint ethSpent) = premineZap.flaunch{value: flaunchingFee + premineFee}(
PositionManager.FlaunchParams({
name: 'Example Memecoin',
symbol: 'EXMPL',
tokenUri: 'ipfs://QmScdsMTXWm3GUvzUwvQvYJLBQjtXwFjWvLgGvPBgipHmg',
initialTokenFairLaunch: 10e27, // 10% fair launch allocation
premineAmount: 5e27, // 5% premine tokens
creator: address(this),
creatorFeeAllocation: 20_00, // 20% dev revs
flaunchAt: block.timestamp + 24 hours, // Launch in 24 hours
initialPriceParams: abi.encode(75_000e6), // $75,000 mcap
feeCalculatorParams: abi.encode(0)
})
);
Last updated
Was this helpful?