Contract Interaction ( Testnet)
This document will help you to build on chain applications using buy & sell methods on the tokens created on pump.flow.
Documentation for Fundamental Functions in PumpFlowTokenFactory (Testnet)
buyTokens
buyTokens
Code Block:
Description:
This function allows users to purchase tokens of a specific meme token using the bonding curve pricing model. The cost is deducted from the user's msg.value
.
Parameters:
memeTokenAddress
: The address of the meme token to be purchased.totalCost
: The total amount (in native currency) the user is willing to spend.
Requirements:
The user must send
msg.value
equal to or greater thantotalCost
.The token must not be blocked or have reached its bonding curve limit.
The available token supply must not exceed the predefined maximum before DEX integration (Maximum 805 million tokens can be sold on curve).
Process:
Verify that the
msg.value
is sufficient.Ensure the token is not blocked and has not exceeded bonding curve thresholds.
Deduct the trading fee from the total cost.
Calculate the number of tokens the user can purchase using the bonding curve formula.
Transfer tokens to the user and update bonding curve metrics (e.g.,
currentSupply
,fundingRaised
).Emit the
TokensPurchased
event.
Events Emitted:
TokensPurchased
: Contains details of the purchase, including the buyer, token address, total cost, number of tokens, and updated bonding curve progress.BondingCurveReached
: Emitted if the purchase causes the token to reach the bonding curve limit.
sellTokens
sellTokens
Code Block:
Description:
This function allows users to sell their meme tokens back to the platform, receiving native blockchain currency in return, as determined by the bonding curve.
Parameters:
memeTokenAddress
: The address of the meme token being sold.numTokens
: The number of tokens the user wants to sell.
Requirements:
The caller must hold at least
numTokens
of the specified meme token.The bonding curve must not have been reached.
The platform contract must have sufficient funds to cover the refund.
The caller must first approve the contract to transfer the specified number of tokens on their behalf using the
approve
function of the token contract.
Process:
Verify that the token is not blocked and has not reached the bonding curve.
Check that the caller holds enough tokens and that the contract has sufficient funds to refund.
Calculate the refund amount using the bonding curve formula.
Deduct the trading fee from the refund amount.
Transfer the tokens from the user to the contract.
Send the refund (minus fees) to the user.
Update bonding curve metrics (e.g.,
currentSupply
,fundingRaised
).Emit the
TokensSold
event.
Events Emitted:
TokensSold
: Contains details of the sale, including the seller, token address, number of tokens, refund amount, and updated bonding curve progress.
getBoundingCurvePercentage
getBoundingCurvePercentage
Code Block:
Description:
Retrieves the percentage progress of a meme token’s current supply relative to its bonding curve threshold.
Parameters:
memeTokenAddress
: The address of the meme token.
Returns:
A percentage value (scaled by 100) indicating the progress towards the bonding curve.
getRemainingTokensInLaunchpad
getRemainingTokensInLaunchpad
Code Block:
Description:
Fetches the remaining token balance in the launchpad for a specific meme token.
Parameters:
memeTokenAddress
: The address of the meme token.
Returns:
The number of tokens remaining in the launchpad.
getAllMemeTokens
getAllMemeTokens
Code Block:
Description:
Returns a list of all meme tokens created through the platform, excluding blocked tokens.
Returns:
An array of
MemeToken
structs containing details of each token.
Notes:
Use this function to retrieve comprehensive information about all active tokens on the platform.
Important Notes for Developers:
Token Approval: Before calling
sellTokens
, ensure you call theapprove
function of the respective meme token contract to allow the factory to handle the tokens on your behalf.
Contract Addresses (Testnet):
PumpFlowTokenFactory:
0xBBfA869CF253aB76742AB9bc7902f783546BC830
PumpFlowTokenFactory Contract ABI:
Meme Token Contract ABI:
Last updated