Lux Standard

Getting Started

Install the Lux Standard Library and deploy your first contract

Getting Started

This guide will help you set up the Lux Standard Library and deploy your first contract.

Prerequisites

  • Foundry installed
  • Node.js 18+ (for SDK usage)
  • A Lux Network RPC endpoint

Installation

# Create a new project
forge init my-lux-project
cd my-lux-project

# Install the contracts library
forge install luxfi/contracts

# Add remappings
echo "@luxfi/contracts/=lib/contracts/" >> remappings.txt

With npm (for SDK)

npm install @luxfi/contracts

Your First Contract

Create a simple token that extends our base contracts:

src/MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@luxfi/contracts/tokens/LRC20.sol";

contract MyToken is LRC20 {
    constructor() LRC20("My Token", "MTK") {
        _mint(msg.sender, 1_000_000 * 10**18);
    }
}

Compile and Test

# Compile
forge build

# Run tests
forge test

Deploy to Lux Testnet

# Set your private key
export PRIVATE_KEY=0x...

# Deploy to Lux Testnet (Chain ID: 96368)
forge create src/MyToken.sol:MyToken \
  --rpc-url https://testnet.lux.network/rpc \
  --private-key $PRIVATE_KEY

Project Structure

After installation, your project should look like:

my-lux-project/
├── lib/
│   └── contracts/          # Lux Contracts Library
│           ├── tokens/     # Token contracts
│           ├── defi/       # DeFi protocols
│           ├── governance/ # DAO & voting
│           └── ...
├── src/
│   └── MyToken.sol         # Your contracts
├── test/
│   └── MyToken.t.sol       # Your tests
├── foundry.toml
└── remappings.txt

Network Configuration

Add Lux networks to your foundry.toml:

foundry.toml
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc = "0.8.24"

[rpc_endpoints]
lux_mainnet = "https://api.lux.network/rpc"
lux_testnet = "https://testnet.lux.network/rpc"

[etherscan]
lux_mainnet = { key = "${LUXSCAN_API_KEY}", url = "https://api.luxscan.io/api" }

Common Imports

Here are the most commonly used imports:

// Tokens
import "@luxfi/contracts/tokens/LUX.sol";           // Native LUX token
import "@luxfi/contracts/tokens/LUXD.sol";          // Lux Dollar stablecoin
import "@luxfi/contracts/tokens/AI.sol";            // AI token with mining
import "@luxfi/contracts/tokens/LRC20.sol";         // Base ERC20
import "@luxfi/contracts/tokens/LRC20B.sol";        // Bridgeable ERC20

// DeFi
import "@luxfi/contracts/synths/AlchemistV2.sol";   // Self-repaying loans
import "@luxfi/contracts/synths/SynthToken.sol";    // Synthetic assets
import "@luxfi/contracts/perps/core/Vault.sol";     // Perpetuals vault

// Governance
import "@luxfi/contracts/governance/DAO.sol";       // DAO contract
import "@luxfi/contracts/governance/Vote.sol";      // Voting
import "@luxfi/contracts/governance/vLUX.sol";      // Vote-escrowed LUX

// Infrastructure
import "@luxfi/contracts/bridge/Teleport.sol";      // Cross-chain bridge
import "@luxfi/contracts/safe/Safe.sol";            // Multi-sig wallet
import "@luxfi/contracts/multicall/Multicall.sol";  // Batch calls

Next Steps

Need Help?

On this page