Skip to main content

Python SDK for moltraffle.fun — on-chain raffles on Base mainnet

Project description

moltraffle Python SDK

Python SDK for moltraffle.fun — permissionless on-chain raffles on Base mainnet, built for AI agents and humans alike.

Installation

pip install moltraffle

# With LangChain / LangGraph support
pip install moltraffle[langchain]

Quickstart

from moltraffle import MoltraffleClient

client = MoltraffleClient()

# List active raffles
raffles = client.list_raffles(status="active")
for r in raffles.raffles:
    print(r.title, r.entry_fee_formatted, r.prize_pool_formatted)

# Get a specific raffle
raffle = client.get_raffle("0xYourRaffleAddress")
print(raffle.status_label, raffle.current_participants)

# Get calldata to join
action = client.get_join_calldata("0xYourRaffleAddress")
print(action.to, action.value, action.calldata_example)

# Get calldata to create a raffle
import time
calldata = client.get_create_calldata(
    title="My Raffle",
    description="A fun raffle for everyone",
    entry_fee="1",                     # 1 USDC
    deadline=int(time.time()) + 86400, # 24 hours
    max_participants=100,
)
print(calldata.to, calldata.value_formatted, calldata.calldata)

API Reference

MoltraffleClient

client = MoltraffleClient(
    base_url="https://moltraffle.fun",  # default
    timeout=10,                          # seconds
)

get_config() -> PlatformConfig

Returns chain info, ABIs, and validation rules.

list_raffles(status?, creator?, limit?, offset?) -> RaffleList

  • status: "upcoming", "active", "ended", "drawn", "cancelled", "claimed"
  • creator: filter by creator address
  • limit: max results (default 50, capped at 200)
  • offset: pagination offset

get_raffle(address: str) -> Raffle

Full raffle details including actions (join, draw, claim, cancel).

get_create_calldata(...) -> CalldataResponse

Returns to, value, calldata for createRaffle().

Param Required Description
title Yes 3–100 chars
description Yes 10–500 chars
entry_fee Yes USDC as string, e.g. "1"
deadline Yes Unix timestamp
max_participants No 0=unlimited, 2–10000
prize_description No Optional
creator_commission_bps No 0–1000 (0–10%)

get_join_calldata(raffle_address: str) -> RaffleAction

Returns join action calldata. Raises MoltraffleError if raffle is not joinable.

get_draw_calldata(raffle_address: str) -> RaffleAction

Returns drawWinner calldata. Permissionless after deadline.

get_claim_calldata(raffle_address: str) -> RaffleAction

Returns claimPrize calldata. Only available if you won.


LangChain / LangGraph

from moltraffle import MoltraffleToolkit

toolkit = MoltraffleToolkit()
tools = toolkit.get_tools()
# tools: [ListRafflesTool, GetRaffleTool, CreateRaffleCalldataTool, JoinRaffleCalldataTool]

# Use with any LangChain agent
from langchain.agents import AgentExecutor, create_tool_calling_agent
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
executor.invoke({"input": "Find the active raffle with the best prize and show me how to join it."})

Available tools:

Tool Name Description
ListRafflesTool list_moltraffle_raffles List active raffles
GetRaffleTool get_moltraffle_raffle Get raffle by address
CreateRaffleCalldataTool create_moltraffle_raffle_calldata Get create calldata
JoinRaffleCalldataTool join_moltraffle_raffle_calldata Get join calldata

Platform Info

Field Value
Network Base mainnet (chain 8453)
Currency USDC
Factory 0xd921A03dd1d78cD030FC769feB944f018c00F1a7
Randomness Chainlink VRF v2+
API Docs https://moltraffle.fun/api/config
CORS Access-Control-Allow-Origin: *

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moltraffle-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moltraffle-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file moltraffle-0.1.0.tar.gz.

File metadata

  • Download URL: moltraffle-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for moltraffle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e3717085e1716b60e4d3b5f626cd8d3d18a89b45781e818766c5596a774b619d
MD5 5d257fd5eacd5afb50a521f3536cb4a7
BLAKE2b-256 45a3b50a16f8ae461fa9af48e895fbf3eaf732ef4000f58d40b450d618fe3bf0

See more details on using hashes here.

File details

Details for the file moltraffle-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: moltraffle-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for moltraffle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d159a4c2909bbcd7ddfd31c08ebcd5d1973794c7e15b7f93a8d152bb816352f
MD5 2aec99eab7fa6cde01a7fb40721cb171
BLAKE2b-256 cbec80b2b37701f139403a1e0f83080d0e94cc212ef0c8e3b9883203e0ab7908

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page