npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pugshole/lilac-contracts

v0.1.0

Published

Reference Solidity contracts for integrating with the Lilac verifiable AI oracle (Base mainnet and supported chains).

Downloads

26

Readme

@pugshole/lilac-contracts

Reference Solidity contracts for integrating with the Lilac verifiable AI oracle.

Live on Base mainnet (chainId 8453) and other supported chains — see https://docs.base-oracle.cloud for the canonical list of Oracle addresses per chain.

Install

# Foundry
forge install maxshtun999/lilac-oracle

# Hardhat / npm
npm install --save-dev @pugshole/lilac-contracts

If you used forge install, add this remapping to your foundry.toml:

remappings = [
    "@pugshole/lilac-contracts/=lib/contracts/src/",
]

Quickstart

Inherit LilacConsumer and override _onLilacAnswer:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {LilacConsumer} from "@pugshole/lilac-contracts/LilacConsumer.sol";
import {IOracle} from "@pugshole/lilac-contracts/IOracle.sol";

contract MyMarket is LilacConsumer {
    event Settled(bytes32 indexed requestId, bool yes, uint8 confidence);

    /// @param oracle The Lilac Oracle address for the chain you're deploying to.
    /// @dev   Base mainnet:  0x... (see docs)
    ///        Arbitrum:      0x... (see docs)
    constructor(address oracle) LilacConsumer(oracle) {}

    /// @notice User-facing entrypoint. Pass in the quote your backend obtained from
    ///         Lilac's REST `/quote` endpoint, signed for `requester = address(this)`.
    function settle(string calldata question, IOracle.QuoteSig calldata quote)
        external
        payable
        returns (bytes32 requestId)
    {
        string[] memory options = new string[](2);
        options[0] = "YES";
        options[1] = "NO";

        requestId = _requestData(question, options, "", quote);
    }

    /// @notice Called by the Lilac Oracle once the node has signed a result.
    function _onLilacAnswer(bytes32 requestId, bytes calldata answer, uint8 confidence)
        internal
        override
    {
        // Decode according to your `rules` schema. Trivial example: first byte = YES/NO.
        bool yes = answer.length > 0 && answer[0] != 0x00;
        emit Settled(requestId, yes, confidence);
    }
}

API surface

LilacConsumer (abstract):

| Member | Visibility | Purpose | |--------------------------------------------------|------------|-------------------------------------------------------------------| | constructor(address oracle_) | public | Pin the trusted Oracle address (immutable). | | LILAC_ORACLE | immutable | The configured Oracle. IOracle-typed. | | _requestData(question, options, rules, quote) | internal | Forward msg.value to oracle.requestData. Returns requestId. | | _claimRefund(requestId) | internal | Call oracle.claimRefund after the timeout has elapsed. | | _onLilacAnswer(requestId, answer, confidence) | internal | Override this. Fires only on Oracle-verified answers. | | oracleCallback(requestId, answer, confidence) | external | Entrypoint the Oracle calls. Gated on msg.sender == oracle. |

Quote signing

LilacConsumer._requestData makes the inheriting contract the requester from the Oracle's point of view. That means your backend must obtain a quote signed for:

  • requester = address(yourConsumerContract)
  • nonce = oracle.nonces(address(yourConsumerContract))

…not for tx.origin or the user's EOA. The Lilac REST /quote endpoint accepts a requester parameter for exactly this case — pass your deployed consumer's address.

Refunds

If the Oracle times out (default 30 minutes), call _claimRefund(requestId) to recover the escrowed ETH. The Oracle refunds the requester — which is your consumer contract, not the original user. Build your own ledger / receive() if you need to forward refunds.

Files

  • src/LilacConsumer.sol — abstract base contract (inherit this).
  • src/ILilacConsumer.sol — callback interface (implement this if you don't inherit).
  • src/IOracle.sol — Oracle interface (types: Tier, Status, QuoteSig, Request, Result).
  • src/IFeeManager.sol — FeeManager interface (getFee(tier) is the useful part).

Security

The Oracle ECDSA-verifies the node's EIP-712 signature against the node bound at request time before invoking oracleCallback. LilacConsumer.oracleCallback additionally gates on msg.sender == LILAC_ORACLE. If you implement ILilacConsumer directly, you must add the same msg.sender check yourself — otherwise anyone can spoof a callback.

The _onLilacAnswer hook is invoked with the Oracle's callbackGasLimit (default 200k). Keep your hook cheap; revert-on-overflow is fine — the Oracle catches it, distributes the node fee, and emits CallbackFailed. Your funds are not at risk on revert, but your answer is lost.

License

MIT