Skip to main content

Simple Lock Smart Contract (1.0.0)

Download OpenAPI specification:Download

The Simple Lock Smart Contract facilitates token locking, which is useful when launching a new token or product. It also provides the ability to unlock tokens or use them in other exchange contracts such as Pair SC or Farm SC.

Overview

The Simple Lock contract enables:

  • Token Locking: Lock any type of token until a specific unlock epoch
  • Token Unlocking: Unlock previously locked tokens after the lock period
  • SFT Representation: Locked tokens are represented as SFT (Semi-Fungible Tokens) at 1:1 ratio

Integration with Router

When creating a new liquidity pair:

  1. Add initial liquidity to receive LP tokens
  2. Lock LP tokens using lockTokens to receive LOCKED SFT
  3. Send LOCKED SFT to Router's setSwapEnabledByUser to activate swaps
  4. Router validates and returns the SFT to the user

Endpoints

Write operations that modify contract state

Lock Tokens

Locks any type of token (including KLV) until a specified unlock epoch. The tokens are converted to LOCKED SFT tokens at a 1:1 ratio.

Process:

  1. User sends tokens as payment along with the unlock epoch
  2. Contract validates the unlock epoch is in the future
  3. Tokens are locked and LOCKED SFT is minted
  4. LOCKED SFT is sent to the destination address (caller by default)

Special Cases:

  • If the unlock epoch has already passed, the original tokens are returned immediately
  • If a LOCKED token with the same metadata already exists, the amount is added to the existing SFT

Payment: Any token type (KLV, KDA fungible, or SFT)

Request Body schema: application/json
required
scAddress
required
string

Simple Lock contract address

funcName
required
string
Value: "lockTokens"
args
required
Array of strings

Arguments:

  • unlock_epoch (u64): The epoch from which the LOCKED token holder can call the unlock endpoint
  • opt_destination (optional, ManagedAddress): Destination address for LOCKED tokens (defaults to caller)
value
required
string

Token payment to lock

Responses

Request samples

Content type
application/json
Example
{
  • "scAddress": "klv1qqqqqqqqqqqqqpgq9696g7x76kwrrh02fahn4rpem4v595t8c0nqgxzpmu",
  • "funcName": "lockTokens",
  • "args": [
    ],
  • "value": "KFIKLVLP-2GC1=1000000"
}

Response samples

Content type
application/json
{
  • "data": {
    },
  • "error": "string",
  • "code": "string"
}

Unlock Tokens

Unlocks tokens that were previously locked using lockTokens. The LOCKED SFT is burned and the original tokens are returned.

Process:

  1. User sends LOCKED SFT as payment
  2. Contract verifies the current epoch is >= unlock epoch
  3. LOCKED SFT is burned
  4. Original tokens are sent to the destination address (caller by default)

Requirements:

  • Current epoch must be greater than or equal to the unlock epoch
  • Payment must be valid LOCKED tokens from this contract

Payment: LOCKED SFT tokens

Request Body schema: application/json
required
scAddress
required
string

Simple Lock contract address

funcName
required
string
Value: "unlockTokens"
args
Array of strings

Arguments:

  • opt_destination (optional, ManagedAddress): Destination address for unlocked tokens (defaults to caller)
value
required
string

LOCKED SFT payment

Responses

Request samples

Content type
application/json
Example
{
  • "scAddress": "klv1qqqqqqqqqqqqqpgq9696g7x76kwrrh02fahn4rpem4v595t8c0nqgxzpmu",
  • "funcName": "unlockTokens",
  • "args": [ ],
  • "value": "LOCK-2U1O/1=1000000"
}

Response samples

Content type
application/json
{
  • "data": {
    },
  • "error": "string",
  • "code": "string"
}