Install
openclaw skills install moonfunsdkPython SDK for BSC enabling creation of AI-generated Meme tokens with stable minting and experimental token trading (buy/sell) features.
openclaw skills install moonfunsdkProfessional Python SDK for creating and trading Meme tokens on Binance Smart Chain with AI-powered image generation.
MoonfunSDK enables automated creation of Meme tokens with AI-generated images on BSC. The SDK handles image generation, platform integration, and blockchain transactions through a simple Python interface.
pip install moonfun-sdk
Requirements:
import os
from moonfun_sdk import MoonfunSDK
# Initialize with private key
sdk = MoonfunSDK(private_key=os.getenv('PRIVATE_KEY'))
# Create Meme token
result = sdk.create_meme(prompt="A happy cat celebrating")
print(f"Token: {result['token_address']}")
print(f"View: https://moonn.fun/detail?address={result['token_address']}")
sdk.create_meme(
prompt: str, # Meme description
symbol: str = None, # Auto-generated if None
description: str = None # Auto-generated if None
) -> dict
Returns:
token_address: Contract addresstoken_id: Platform token IDtx_hash: Creation transaction hashname: Token namesymbol: Token symbolimage_url: Hosted image URLsdk.buy_token(token_address: str, bnb_amount: float, slippage: float = 0.1)
sdk.sell_token(token_address: str, amount: int, slippage: float = 0.1)
sdk.get_balance() # Returns BNB balance
sdk.get_token_balance(token_address: str) # Returns token balance (wei)
SDK comes pre-configured with hosted services:
No additional configuration needed for basic usage.
sdk = MoonfunSDK(
private_key="0x...",
image_api_url="https://custom-api.com", # Optional
platform_url="https://moonn.fun", # Default
rpc_url="https://bsc-dataseed.bnbchain.org" # Default
)
Supported environment variables:
PRIVATE_KEY (required): Ethereum private keyMOONFUN_IMAGE_API_URL (optional): Custom image API endpointPrivate keys are used locally only for:
Private keys are NEVER:
Users can audit private key usage in source code:
auth.py: Local signing with eth_accountimage_api.py: Sends only signature + addressplatform.py: Sends only signature + addressblockchain.py: Local transaction signing via web3.py# ✅ Use environment variables
sdk = MoonfunSDK(private_key=os.getenv('PRIVATE_KEY'))
# ✅ Use dedicated wallets
# Create new wallet for SDK operations only
# ❌ Never hardcode keys
sdk = MoonfunSDK(private_key="0x123...") # Don't do this
0x953C65358a8666617C66327cb18AD02126b2AAA50xBB4CdB9CBd36B01bD1cBaEBF2De08d9173bc095cAll addresses are public and verifiable on BSCScan.
from moonfun_sdk import (
InsufficientBalanceError,
AuthenticationError,
TransactionFailedError
)
try:
result = sdk.create_meme("A funny cat")
except InsufficientBalanceError:
print("Need more BNB (minimum 0.011)")
except AuthenticationError:
print("Signature verification failed")
except TransactionFailedError:
print("Blockchain transaction failed")
The SDK uses these services:
Image Generation API
http://moonfun.siteMoonnFun Platform
BSC Network
Core dependencies:
web3>=6.0.0 - Ethereum interactioneth-account>=0.8.0 - Private key managementrequests>=2.28.0 - HTTP clienthttpx>=0.24.0 - Async HTTP clientAll dependencies are widely used and audited libraries.
# Clone repository
git clone <repository-url>
cd moonfun-sdk/python
# Review source code
cat moonfun_sdk/auth.py # Private key handling
cat moonfun_sdk/image_api.py # API requests
cat moonfun_sdk/platform.py # Platform integration
# Install from source
pip install -e .
| Issue | Solution |
|---|---|
| InsufficientBalanceError | Add BNB (minimum 0.011) |
| AuthenticationError | Check private key format (needs 0x prefix) |
| TransactionFailedError | Increase slippage or check gas |
| RPCConnectionError | Try different RPC endpoint |
MIT License
This SDK interacts with blockchain and requires real BNB. Users should:
Trading features are experimental and may have issues with new/low-liquidity tokens.