get_arbitrum_invoice
Retrieve an invoice to pay for semantic web search with ETH on Arbitrum as an alternative to Lightning Network payments.
Instructions
Get payment info to pay with ETH on Arbitrum instead of Lightning.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:97-107 (handler)The get_arbitrum_invoice MCP tool handler function. Gets payment info for Arbitrum ETH payments by calling arb_pay.get_invoice_info('search'). Returns payment details including price in ETH, contract address, service ID, and instructions.
@mcp.tool() def get_arbitrum_invoice() -> str: """Get payment info to pay with ETH on Arbitrum instead of Lightning.""" info = arb_pay.get_invoice_info("search") return ( f"Pay {info['price_eth']} ETH on {info['network']}.\n\n" f"Contract: {info['contract']}\n" f"Service ID: {info['service_id']}\n\n" f"{info['instructions']}\n" f"Then call search_web or search_news with the tx_hash." ) - server.py:97-107 (registration)The @mcp.tool() decorator registers the get_arbitrum_invoice function as an MCP tool. This is the registration point for the tool.
@mcp.tool() def get_arbitrum_invoice() -> str: """Get payment info to pay with ETH on Arbitrum instead of Lightning.""" info = arb_pay.get_invoice_info("search") return ( f"Pay {info['price_eth']} ETH on {info['network']}.\n\n" f"Contract: {info['contract']}\n" f"Service ID: {info['service_id']}\n\n" f"{info['instructions']}\n" f"Then call search_web or search_news with the tx_hash." ) - arb_pay.py:66-81 (helper)Helper function get_invoice_info() that returns payment data for on-chain Arbitrum payments. Defines network, contract address, service ID mapping, price in wei and ETH, and payment instructions.
def get_invoice_info(service: str) -> dict: """Retorna los datos para que el agente pague on-chain.""" sid = SERVICE_IDS.get(service) price = SERVICE_PRICES.get(service, 0) chain = "arbitrum-one" if "sepolia" in ARBITRUM_RPC else "arbitrum-one" return { "network": chain, "contract": CONTRACT_ADDRESS, "service_id": sid, "price_wei": price, "price_eth": str(Web3.from_wei(price, "ether")), "instructions": ( f"Call pay({sid}) on the contract sending {price} wei. " "Then pass the transaction hash to the tool." ), }