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: *

Links

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.1.tar.gz (7.5 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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moltraffle-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 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.1.tar.gz
Algorithm Hash digest
SHA256 e5db53ee83d58fe651537ead69bbde838ae989024ca783fc312605f9cab1be61
MD5 ba05e2cd1f0eac94b2c7e841782611b9
BLAKE2b-256 62681ca1f3fa6f4b4a2b3402fbd1d0c5fd69b9a0ca2f17335f05a8f522960c50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: moltraffle-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef99db385a659300fe3ff32932524e82f17f4e6a96346bba0e1c0c1e37eb9e08
MD5 8420422d6c995f27f7ca4360f403a981
BLAKE2b-256 05edaca401e5c9b51857a5a7fe982307d6df6e14d3341cc9db40424e086c1c13

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