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

@fxnlabs/v1-contracts

v0.0.5

Published

Function Network is a decentralized infrastructure designed to power AI inference workloads. Function Network democratizes access to AI compute by enabling anyone with computational resources to participate. Gateways facilitate seamless interaction for us

Downloads

30

Readme

Function Network

Function Network is a decentralized infrastructure designed to power AI inference workloads. Function Network democratizes access to AI compute by enabling anyone with computational resources to participate. Gateways facilitate seamless interaction for users, while providers execute computational tasks defined by cutting-edge AI models.

At its core, Function Network utilizes FUNC, a blockchain-based token, to enable staking, governance, and reward distribution, ensuring efficiency and trust within the system. By connecting compute providers, gateways, and AI models, the network creates a scalable, transparent, and incentive-driven ecosystem.

Table of Contents

Benefits of Function Network

  1. Decentralized AI Infrastructure: Democratizes access to AI compute, enabling fair and transparent participation.
  2. Scalable and Flexible: Dynamically supports multiple models, providers, and gateways for evolving AI workloads.
  3. Fair Reward System: Checkpoints and performance tracking ensure transparent distribution of FUNC rewards.

Key Features

1. Decentralized AI Inference

Function Network enables AI inference tasks to be processed through a decentralized network:

  • AI Models: Define specific computational workloads (e.g., image recognition, NLP).
  • Providers: Supply computational power to execute these tasks.
  • Gateways: Act as the interface between users and the network.

2. Staking and Rewards

Participants stake FUNC tokens to contribute to the network and earn rewards:

  • Providers: Stake FUNC to support AI models and earn FUNC based on their contributions.
  • Gateways: Stake FUNC to act as intermediaries and earn rewards for routing user requests.

3. Transparent Reward Distribution

Rewards are allocated based on performance metrics:

  • Epoch-based Rewards: Incentives are distributed periodically at the end of each epoch.
  • Checkpointing: Tracks historical contributions for accurate reward calculations.

4. Scalable Infrastructure

The Function Network dynamically scales with demand:

  • Providers can support multiple models to maximize their earnings.
  • Gateways ensure seamless routing and scalability for users.

How It Works

  1. Registration Providers and gateways register on the network, linking their accounts to specific models or operations.

  2. Staking Providers and gateways stake FUNC tokens to participate in the network. Staking ensures accountability and incentivizes contributions.

  3. Task Execution Providers execute tasks defined by AI models, while gateways route requests to the appropriate providers.

  4. Reward Distribution Rewards are calculated and distributed at the end of each epoch based on contributions and performance.

How to Participate

For Providers

To participate as a provider:

  1. Register your provider ID and link it to a specific AI model.
  2. Stake FUNC tokens as required by the model.
  3. Execute Tasks: Provide computational resources to support AI inference workloads.
  4. Claim Rewards: Collect FUNC rewards based on your performance.
  5. Unstake: After meeting the minimum lock period, unstake your FUNC tokens if desired.

For Gateways

To participate as a gateway:

  1. Register your gateway ID and add metadata for identification.
  2. Stake FUNC tokens to activate your gateway.
  3. Facilitate Requests: Route user requests to the appropriate providers.
  4. Claim Rewards: Earn FUNC based on your routing and performance.
  5. Unstake: Deactivate and unstake FUNC tokens when no longer operating.

Core Components

FUNC Token

FUNC is the native utility token of the Function Network. It powers the ecosystem by:

  • Staking: Required for providers and gateways to participate.
  • Rewards: Distributed to contributors based on performance.
  • Governance (Roadmap): FUNC holders influence decisions about the network's evolution.

Providers

Providers supply computational resources for running AI models. They:

  • Stake FUNC to participate.
  • Execute AI inference tasks and earn FUNC rewards.
  • Support specific models by aligning with their staking and performance requirements.

Gateways

Gateways enable users to interact with the network. They:

  • Stake FUNC to operate.
  • Route user requests to providers and ensure task execution.
  • Earn FUNC for their role in connecting users to the network.

Models

AI models define the computational workloads to be executed on the network. Each model:

  • Specifies computational requirements like shards and compute units.
  • Requires providers to stake FUNC to support them.

Router

The Router acts as the central management hub, connecting providers, gateways, models, and other core components.

Treasury

The Treasury manages FUNC tokens and ensures accurate reward distribution to providers and gateways.

Checkpoints

Checkpoint contracts track contributions and performance over time:

  • Provider Checkpoints: Monitor provider activity and shards contributed.
  • Gateway Checkpoints: Track gateway usage and compute units consumed.

Tokenomics

FUNC Token Utility

  1. Staking: FUNC tokens must be staked by providers and gateways to participate in the network.
  2. Rewards: FUNC tokens are distributed to staked participants based on their contributions to the network.
  3. Governance: FUNC tokens may be used for proposal voting and treasury management in the future.

Earning Potential

  • Providers and gateways earn FUNC based on the shards (work) they contribute during each epoch.
  • Example:
    • If the total reward pool for an epoch is 10,000 FUNC and a provider contributes 10% of the shards, they earn 1,000 FUNC.

Economic Design

  1. Fixed Supply:
    • FUNC tokens have a fixed supply, with no inflationary mechanisms, ensuring scarcity and value retention.
  2. Treasury Management:
    • FUNC tokens in the treasury are allocated for ecosystem development, community initiatives, and network rewards.

Understanding Fees in the FUNC Ecosystem

The FUNC ecosystem implements a dynamic mechanism for calculating burn amounts based on consumed Compute Units (CU). This mechanism ensures fairness by rewarding users who stake more FUNC tokens or commit to longer staking durations. Below is an overview of how burn amounts are determined and the various discount mechanisms available.

[!IMPORTANT] Burn is disabled on network launch and for the foreseeable future

Fee Calculation

The fee is the FUNC tokens deducted based on consumed Compute Units (CU). It is calculated as:

Fee = CU Consumed × Fee Multiplier × Conversion Factor

Where:

  • Fee Multiplier: Determined dynamically based on stake size and staking duration.
  • Conversion Factor: Adjusts the relationship between CU and FUNC, defined by a configurable numerator and denominator:
    • Conversion = (CU × Denominator) / Numerator
    • This ensures flexibility in setting CU-to-FUNC ratios, which may vary based on network needs.

Types of Discounts

  1. Stake-Based Discounts

    • Users with higher FUNC stakes qualify for lower fees.
    • Discount tiers define minimum stake levels and their associated fees (expressed as percentages).
    • Example:
      • Stake ≥ 5000 FUNC: Fee = 95%
      • Stake ≥ 1000 FUNC: Fee = 97%
      • Stake < 1000 FUNC: Fee = 100% (no discount)
  2. Duration-Based Discounts

    • Users who stake FUNC for longer durations qualify for additional discounts.
    • Discount tiers define minimum staking durations (measured in epochs) and their associated discounts.
    • Example:
      • Staked for ≥ 180 epochs (6 months): Discount = 5%
      • Staked for ≥ 30 epochs (1 month): Discount = 2%

Additive Discount Mechanism

The total fee multiplier applied to the Fee is calculated as:

Final Fee = Stake-Based Fee - Duration Discount
  • Stake-Based Fee: Based on the user’s FUNC stake amount.
  • Duration Discount: Based on the user’s staking duration (in epochs).
  • The final fee cannot go below 0%.

Example Calculation

User Parameters:

  • Compute Units Consumed: 100 CU
  • FUNC Staked: 5000 FUNC (qualifies for a 95% fee).
  • Staking Duration: 6 months (qualifies for a 5% discount).
  • Conversion Factor: Numerator = 1, Denominator = 2 (1 CU Costs 2 FUNC).

Calculation:

  1. Stake-Based Fee: 95% (9500 basis points).

  2. Duration Discount: 5% (500 basis points).

  3. Final Fee: 95% - 5% = 90% (9000 basis points).

  4. Fee:

    Fee = (CU Consumed × Final Fee In Basis × Denominator) / (Numerator × Basis Denominator)
                = (100 × 9000 × 2) / (1 × 10000)
                = 180 FUNC

Key Takeaways

  1. Flexible Conversion: CU and FUNC are not always 1:1. The conversion factor (numerator and denominator) allows adjustments to the CU-to-FUNC ratio to meet network needs.
  2. Stake-Based Discounts: Encourages users to stake more FUNC by reducing fees for higher stakes.
  3. Duration-Based Discounts: Rewards users who commit to longer staking periods.
  4. Fair Mechanism: The additive discount approach ensures fairness, combining discounts without compounding.

This mechanism incentivizes greater participation and long-term commitment, promoting network stability and security.

Staking Workflows for Function Network

Below are detailed workflows for registering, staking, unstaking, claiming rewards, and winding down for both Gateways and Providers within the Function Network.

Gateway Staking Workflows

1. Registering a Gateway

Gateways must be registered before staking FUNC tokens. Registration associates metadata and allows the Gateway to participate in the network.

Steps
  1. Call register in GatewayRegistry:
    • Provide a unique id (max 64 bytes) and optional metadata (max 1024 bytes).
    • Metadata is intended for descriptive information about the Gateway, such as its role or identifier.
  2. Auto-whitelisting (if enabled):
    • The gateway will automatically be whitelisted for participation.
  3. Emit event: GatewayRegistered.

Example:

register("unique-gateway-id", "My Gateway Metadata")

2. Staking FUNC for a Gateway

Once registered, the Gateway owner can stake FUNC tokens to participate in the network.

Steps
  1. Determine Stake Amount:
    • Ensure you have enough FUNC tokens to stake.
    • Transfer FUNC tokens to the GatewayRegistry contract.
  2. Call registerAndStake:
    • Provide the id, metadata, and amount of FUNC tokens to stake.
  3. Auto-update Staking Contract:
    • The FUNC tokens are approved and forwarded to the GatewayStaking contract.
  4. Emit event: GatewayRegisteredAndStaked.

Example:

registerAndStake("unique-gateway-id", "My Gateway Metadata", 1000 * 10**18)

3. Wind Down a Gateway

Gateways must be wound down before they can be unstaked. This marks the gateway for eventual deactivation.

Steps
  1. Call windDownGateways in GatewayStaking:
    • Provide a list of gateway IDs to wind down.
  2. Wait for the wind-down delay:
    • A specified delay period (defined in EpochController) must pass before the gateway can be unstaked.
  3. Emit event: GatewayWoundDown.

Example:

windDownGateways(["unique-gateway-id"])

4. Unstaking a Gateway

To retrieve staked FUNC tokens, the gateway must complete the wind-down and lock periods defined by the system.

Steps
  1. Ensure Wind-Down Delay is Complete:
    • Gateways must meet the wind-down delay requirement before unstaking.
  2. Ensure Minimum Lock Period Elapsed:
    • Gateways must also meet the minEpochsLocked requirement.
  3. Call unstakeForGateway in GatewayStaking:
    • Provide the id of the gateway to unstake FUNC.
  4. FUNC Transfer:
    • The FUNC tokens are transferred back to the gateway owner.
  5. Emit event: GatewayUnstaked.

Example:

unstakeForGateway("unique-gateway-id")

5. Claiming Rewards

Gateways earn FUNC rewards based on compute usage and participation metrics.

Steps
  1. Ensure Rewards Are Delayed:
    • Rewards can only be claimed for epochs up to currentEpoch - epochRewardDelay as defined in EpochController.
  2. Call claimRewards in GatewayStaking:
    • Provide the id and range of epochs for claiming rewards.
  3. Emit event: GatewayClaimedRewards.
claimRewards("unique-gateway-id", 10, 20)

Provider Staking Workflows

1. Registering a Provider

Providers must be linked to a specific model and registered before staking.

Steps
  1. Call register in ProviderRegistry:
    • Provide a unique id (max 64 bytes), modelId, and optional metadata.
    • Metadata: The metadata field for a provider is intended to be the URL to access the provider's node, enabling connection to its services.
  2. Auto-whitelisting (if enabled):
    • The provider will automatically be whitelisted for participation.
  3. Emit event: ProviderRegistered.
register("unique-provider-id", 1, "https://provider-node.example.com")

2. Staking FUNC for a Provider

Providers must meet the required stake amount defined by the model.

Steps
  1. Determine Stake Amount:
    • Check the model's required stake amount using modelStakeAmount.
  2. Call registerAndStake:
    • Provide the id, modelId, metadata, and FUNC stake amount.
  3. Emit event: ProviderRegisteredAndStaked.

Example:

registerAndStake("unique-provider-id", 1, "https://provider-node.example.com")

3. Unstaking a Provider

To retrieve staked FUNC tokens, providers must ensure all lock periods and requirements are met.

Steps
  1. Ensure Minimum Lock Period Elapsed:
    • Providers must meet the minEpochsLocked requirement.
  2. Call unstakeProvider in ProviderStaking:
    • Provide the id of the provider to unstake FUNC.
  3. FUNC Transfer:
    • The FUNC tokens are transferred back to the provider owner.
  4. Emit event: ProviderUnstaked.

Example:

unstakeProvider("unique-provider-id")

4. Claiming Rewards

Providers earn FUNC rewards based on shard contributions and participation metrics.

Steps
  1. Ensure Rewards Are Delayed:
    • Rewards can only be claimed for epochs up to currentEpoch - epochRewardDelay as defined in EpochController.
  2. Call claimRewardsCluster:
    • Provide the range of epochs to claim rewards for all providers owned by the caller.
  3. Emit event: RewardClaimedForCluster.

Example:

claimRewardsCluster(10, 20)

Common Notes

  • Wind-Down Delay: Gateways must wait a specified number of epochs after calling windDownGateways before unstaking.
  • Minimum Epochs Locked: Applies to both Gateways and Providers. Check this value using minEpochsLocked in EpochController.
  • Reward Delay: Rewards can only be claimed for epochs up to currentEpoch - epochRewardDelay.
  • Provider Metadata: The metadata for a provider is typically the URL to access its node, enabling external systems to connect and send inference requests.
  • FUNC Token Approvals: Always approve FUNC transfers before staking.

Provider and Gateway Active Status

Provider Active Status

A Provider is considered Active if the following conditions are met:

  1. Registered: The provider has been registered in the Function Network.
  2. Not Deactivated: The provider has not been explicitly deactivated.
  3. Sufficiently Staked: The provider has staked an amount of FUNC tokens equal to or greater than the modelStakeAmount for the associated model.
  4. Whitelisted: The provider is whitelisted.
  5. Model is Active: The model associated with the provider is enabled and functional.

Gateway Active Status

A Gateway is considered Active if the following conditions are met:

  1. Registered: The gateway has been registered in the Function Network.
  2. Not Deactivated: The gateway has not been explicitly deactivated.
  3. Effective Stake Amount: The gateway has an effective stake balance that is not overdrawn.
  4. Whitelisted: The gateway is whitelisted.

Roadmap for Governance and Protocol Changes

Short-Term Goals (1–6 Months)

  1. Parameter Adjustment Mechanism:

    • Allow the community to vote on epoch length, reward delay, and staking requirements.
    • Provide an interface for transparent proposal submissions.
  2. Enhanced Whitelist Governance:

    • Decentralize the whitelisting process to allow token holders to propose and vote on new providers and gateways.
  3. Documentation and Usability Improvements:

    • Expand network documentation, including tutorials for onboarding providers and gateways.
    • Develop an intuitive dashboard for users to manage their stakes and monitor rewards.

Medium-Term Goals (6–12 Months)

  1. Dynamic Reward Adjustment:

    • Implement a model to dynamically adjust staking and reward parameters based on network usage and demand.
  2. AI Model Voting:

    • Enable community proposals to add new AI models to the Function Network, with voting on model acceptance and staking requirements.
  3. Transparency Dashboard:

    • Build a dashboard displaying governance decisions, staking statistics, and reward distributions.

Long-Term Goals (12+ Months)

  1. Community-Owned Treasury:

    • Transition the treasury to community control, enabling FUNC holders to propose and approve funding for initiatives.
  2. Cross-Chain Expansion:

    • Launch support for other blockchain ecosystems and allow cross-chain staking and rewards.
  3. Protocol Upgrades:

    • Allow community-led protocol upgrades, including smart contract improvements and feature additions.

Dev Documentation

Check out our developer documentation here.

Glossary of Terms

Function Network Core Concepts

  • Function Network: A decentralized system designed for AI inference, connecting Gateways (clients) to Providers (AI model operators) through a tokenized staking and reward mechanism.
  • FUNC Token: The native utility token of the Function Network, used for staking, rewarding, and facilitating transactions.
  • Provider: An operator hosting and maintaining AI inference models, offering services through the Function Network.
  • Gateway: An entity that connects users to providers, aggregating and routing AI inference requests.
  • Epoch: A fixed time period (in blocks) during which staking, rewards, and network activities are synchronized.
  • Shard: A unit of work or compute contribution attributed to providers, determining rewards.
  • Stake: FUNC tokens locked to participate in network operations, either as a provider or gateway.
  • Whitelist: A status allowing providers or gateways to participate in the network.
  • Jail: A status temporarily restricting a provider or gateway due to violations or inactivity.

FAQ

General Questions

  1. What is the Function Network?

    • A decentralized system for AI inference, connecting gateways to AI providers using FUNC tokens for staking and rewards.
  2. What are FUNC tokens used for?

    • FUNC tokens are used for staking by providers and gateways, distributed as rewards, and may be used for governance in the future.
  3. What is an epoch, and how does it work?

    • An epoch is a time period defined by a fixed number of blocks during which network activities like staking and rewards are synchronized.
  4. How are rewards calculated?

    • Rewards are based on the shards (units of work) contributed by providers within an epoch, distributed proportionally from the epoch’s reward pool.
  5. What is the significance of minEpochsLocked?

    • This is the minimum number of epochs for which FUNC tokens must remain staked before they can be unstaked.

Provider Questions

  1. What is required to register as a provider?

    • Register with metadata (typically the URL for the node), stake the required FUNC tokens, and ensure the provider is whitelisted.
  2. What happens if I don’t claim my rewards?

    • Rewards remain claimable indefinitely but are subject to the epoch reward delay before they become available.
  3. What is the penalty for being jailed?

    • Jailed providers cannot participate in staking or claim rewards during the jail period.
  4. What does the metadata of a provider represent?

    • The metadata is typically the URL where the provider’s node can be accessed for inference requests.

Gateway Questions

  1. How do gateways interact with providers?

    • Gateways aggregate client requests and route them to the appropriate providers based on availability and compute requirements.
  2. Can gateways unstake immediately?

    • No, gateways must initiate a wind-down process, followed by a staking delay before they can unstake.
  3. What metadata do gateways need?

    • Gateways typically include routing-related metadata like endpoint URLs or regional availability.

Get Involved

To join the Function Network as a provider, gateway, or developer:

  1. Obtain FUNC tokens.
  2. Register and stake on the network.
  3. Start contributing and earning FUNC rewards!

Join the Function Network and power the future of decentralized computation! For more information or questions, check us out at Function Network.