> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlayer.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Builder Codes

> Build applications and earn fees on orders you facilitate

## Overview

Builder codes allow developers and builders to receive fees on orders they send on behalf of users. This enables builders to monetize their applications while providing value to traders.

<Info>
  The term "builder" refers to **DeFi builders** who build applications on Token Layer, not block builders within consensus.
</Info>

## How Builder Codes Work

### Fee Mechanism

Builder codes enable builders to:

1. **Facilitate orders** on behalf of users through their application
2. **Earn a fee** on each order they process
3. **Set fees per-order** for maximum flexibility

### User Approval Required

<Warning>
  Users must explicitly **approve a maximum builder fee** for each builder before the builder can charge fees
</Warning>

* Users have full control over which builders can charge fees
* Users can see the maximum fee a builder may charge
* Users can **revoke permissions at any time**

## Technical Implementation

### Onchain Processing

<Check>
  Builder codes are processed **entirely onchain** as part of the fee logic
</Check>

This ensures:

* Transparency in fee calculations
* Trustless execution
* Verifiable fee distribution

### Per-Order Flexibility

Builders can set fees **per-order**, allowing for:

* Dynamic pricing based on order size
* Different fees for different types of orders
* Promotional pricing for certain users
* Volume-based discounts

## Use Cases

### Trading Bots

Build automated trading bots that:

* Execute strategies on behalf of users
* Charge a fee per trade
* Provide value through automation and optimization

### Portfolio Management Tools

Create applications that:

* Rebalance portfolios automatically
* Charge fees for management services
* Optimize tax efficiency

### Social Trading Platforms

Develop platforms where:

* Expert traders create strategies
* Followers execute the same trades
* Builders earn fees on follower trades

### Aggregators

Build aggregation services that:

* Find best prices across multiple chains
* Route orders optimally
* Charge fees for routing services

### Custom UIs

Create specialized interfaces that:

* Cater to specific user segments
* Provide unique features or UX
* Monetize through builder fees

## Setting Up Builder Codes

### Requirements

To implement builder codes, you need:

1. **API Integration**: Integrate with Token Layer's API
2. **User Approval Flow**: Implement a way for users to approve your builder fee
3. **Fee Logic**: Determine how you'll calculate fees per order

### Implementation Steps

<Steps>
  <Step title="Register as a Builder">
    Contact Token Layer to register your builder code
  </Step>

  <Step title="Integrate API">
    Use the trade endpoints with your builder code parameter
  </Step>

  <Step title="Request User Approval">
    Implement UI for users to approve your maximum fee
  </Step>

  <Step title="Process Orders">
    Send orders on behalf of users with your builder code
  </Step>

  <Step title="Earn Fees">
    Automatically receive fees as orders are executed
  </Step>
</Steps>

## Fee Guidelines

### Competitive Fees

Consider market rates when setting builder fees:

* **Simple execution**: 5-10 bps
* **Advanced strategies**: 10-25 bps
* **Premium features**: 25-50 bps

### Transparency

<Tip>
  Always be clear about your fees upfront. Users appreciate transparency and are more likely to approve fair fees.
</Tip>

Display to users:

* Maximum potential fee
* Typical fee ranges
* Value you're providing
* How to revoke access

## User Permissions

### Approval Process

Users approve builder fees through:

1. **Maximum Fee Setting**: Users set the maximum fee you can charge
2. **Scope**: Approval can be for all trades or specific tokens
3. **Duration**: Users control how long approval lasts

### Revocation

Users can revoke builder permissions:

* **Instantly**: Takes effect immediately
* **No exit penalty**: Users can leave at any time
* **Full control**: Users own their funds and relationships

## API Integration

### Trade Endpoints

When sending trades with builder codes, use:

<CardGroup cols={2}>
  <Card title="Trade Tokens" icon="code" href="/api-reference/transactions/trade-tokens-buy-or-sell">
    POST /trade-token (with builder code parameter)
  </Card>

  <Card title="Token Layer Actions" icon="code" href="/api-reference/transactions/execute-token-layer-action">
    POST /token-layer (with builder code parameter)
  </Card>
</CardGroup>

### Example Request

```json theme={null}
{
  "token_id": "token_123",
  "amount": 1000,
  "side": "buy",
  "builder_code": "YOUR_BUILDER_CODE",
  "builder_fee_bps": 10
}
```

## Fee Distribution

### Receiving Fees

Builder fees are:

* **Automatically deducted** from each order
* **Sent to your builder account**
* **Claimable** once they exceed the minimum threshold
* **Trackable** in real-time

### Claiming Process

<Steps>
  <Step title="Accrue Fees">
    Fees accumulate as users trade through your app
  </Step>

  <Step title="Monitor Balance">
    Track earnings at app.tokenlayer.network/earn
  </Step>

  <Step title="Claim">
    Claim once balance exceeds \$1
  </Step>

  <Step title="Receive">
    Fees are added to your spot balance
  </Step>
</Steps>

## Best Practices

### Provide Real Value

<Check>
  Users will only approve builder fees if you provide clear value
</Check>

Focus on:

* Superior execution quality
* Unique features or insights
* Time-saving automation
* Better prices or lower slippage

### Competitive Pricing

* Research competitor fees
* Start with lower fees to attract users
* Increase fees as you prove value
* Consider volume discounts for power users

### Clear Communication

* Explain what users get for the fee
* Show fee calculations before execution
* Provide receipts after trades
* Be responsive to user questions

### Maintain Trust

* Never charge more than approved maximum
* Honor user revocations immediately
* Keep user funds secure
* Be transparent about any issues

## Example Applications

### DeFi Dashboard Builder

**Value Proposition**: All-in-one interface for Token Layer with advanced charting

**Builder Fee**: 8 bps per trade

**Revenue Model**: $100,000 daily volume = $80/day in fees

### Copy Trading Platform

**Value Proposition**: Follow top traders automatically

**Builder Fee**: 15 bps on follower trades

**Revenue Model**: 100 users × $1,000/day × 15 bps = $150/day

### Telegram Trading Bot

**Value Proposition**: Trade directly from Telegram

**Builder Fee**: 10 bps per trade

**Revenue Model**: 500 users × $500/day × 10 bps = $250/day

## Compliance Considerations

As a builder earning fees:

* You may be providing a financial service in certain jurisdictions
* Understand your local regulations around:
  * Payment processing
  * Financial services
  * Securities (if applicable)
  * Tax reporting

<Warning>
  Consult with legal counsel about your specific builder application and jurisdiction
</Warning>

## Support for Builders

### Resources

* **API Documentation**: Complete reference for integration
* **Builder Community**: Discord channel for builders
* **Technical Support**: Dedicated support for integration questions

### Getting Started

Interested in building with builder codes?

1. Join the [Token Layer Discord](https://discord.gg/tokenlayer)
2. Review the [API documentation](/api-reference)
3. Click the chat icon in the bottom right corner to get started

## Questions?

For more information about builder codes, click the chat icon in the bottom right corner to get help.
