Smart Contracts
MemeTrade is built on a modular smart contract architecture on Base, providing secure and efficient token creation and trading.
Overview
MemeTrade's smart contracts are designed to be flexible and extensible, allowing for a wide range of tokenomics and governance models. The platform leverages the security and scalability of Base to offer a seamless experience for users and developers alike.
Key Contracts
Factory Contract: Deploys new token instances and manages platform templates.
Governance Contract: Facilitates community proposals and voting.
Economic Module: Handles fee distribution and liquidity mining rewards.
Template Module: Manages token templates and associated fees.
Security
All contracts are audited by leading security firms and are open source for community review. MemeTrade also offers a bug bounty program to encourage responsible disclosure of vulnerabilities.
Getting Started
To start building on MemeTrade, check out our Developer Guide for detailed instructions on integrating with our smart contracts.
Core Contracts
Factory Contract
The main contract that handles token creation and manages the platform.
Key Functions:
createToken()
- Deploy new meme tokensupdateTemplate()
- Modify token templatessetGovernance()
- Update governance settings
Address (Base Sepolia): 0x[CONTRACT_ADDRESS]
Template Contracts
Modular templates that define token behavior and economics.
ViralTemplate
Implements viral mechanics for meme tokens
Handles holder rewards and burn mechanisms
Manages creator fees and governance
StandardTemplate
Basic ERC-20 functionality
Simple tokenomics
Minimal gas usage
Governance Contract
Manages platform governance and proposal voting.
Key Functions:
propose()
- Submit governance proposalsvote()
- Cast votes on proposalsexecute()
- Execute passed proposals
Liquidity Mining Helper
Facilitates liquidity mining rewards and pool management.
Key Functions:
addLiquidity()
- Add liquidity to poolsclaimRewards()
- Claim mining rewardsgetRewardInfo()
- View reward details
Architecture Overview
┌─────────────────┐ ┌──────────────────┐
│ Factory │────│ Templates │
│ │ │ - Viral │
│ - Create Token │ │ - Standard │
│ - Governance │ │ - Custom │
└─────────────────┘ └──────────────────┘
│ │
│ ┌────────────────┐
└──────────────│ Token │
│ Instance │
│ │
│ - ERC-20 │
│ - Mechanics │
└────────────────┘
Integration Guide
Creating Tokens Programmatically
// Connect to Factory contract
IFactory factory = IFactory(FACTORY_ADDRESS);
// Create token parameters
TokenParams memory params = TokenParams({
name: "My Meme Token",
symbol: "MMT",
totalSupply: 1000000 * 10**18,
initialPrice: 0.001 ether,
creatorFee: 300 // 3%
});
// Deploy token
address tokenAddress = factory.createToken(
VIRAL_TEMPLATE_ID,
params,
viralMechanics
);
Interacting with Tokens
// Connect to deployed token
ITemplate token = ITemplate(tokenAddress);
// Buy tokens
token.buy{value: ethAmount}(minTokens);
// Sell tokens
token.sell(tokenAmount, minEth);
// Check creator fees earned
uint256 fees = token.getCreatorFees(creatorAddress);
Adding Liquidity
// Connect to Liquidity Mining Helper
ILiquidityMiningHelper helper = ILiquidityMiningHelper(HELPER_ADDRESS);
// Add liquidity to pool
helper.addLiquidity{value: ethAmount}(
tokenAddress,
tokenAmount,
minEth,
minTokens,
deadline
);
Contract ABIs
All contract ABIs are available in our GitHub repository:
Development Setup
Prerequisites
Node.js 18+
Foundry
Git
Installation
git clone https://github.com/memetrade/contracts
cd contracts
npm install
forge install
Testing
# Run all tests
forge test
# Run specific test
forge test --match-contract FactoryTest
# Run with gas reporting
forge test --gas-report
Deployment
# Deploy to Base Sepolia
forge script script/Deploy.s.sol --rpc-url $BASE_SEPOLIA_RPC
# Verify contracts
forge verify-contract $CONTRACT_ADDRESS Contract
Event Reference
Factory Events
event TokenCreated(
address indexed token,
address indexed creator,
string name,
string symbol
);
event TemplateUpdated(
uint256 indexed templateId,
address indexed newImplementation
);
Token Events
event TokensBought(
address indexed buyer,
uint256 ethAmount,
uint256 tokenAmount
);
event TokensSold(
address indexed seller,
uint256 tokenAmount,
uint256 ethAmount
);
Gas Optimization
Typical Gas Costs
Token Creation: ~150,000 gas
Token Purchase: ~80,000 gas
Token Sale: ~75,000 gas
Add Liquidity: ~120,000 gas
Optimization Tips
Batch operations when possible
Use appropriate gas limits
Monitor Base network congestion
For more technical details, see our Integration Guide or check the Contract Addresses page.
Last updated