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.
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
When creating a new liquidity pair:
- Add initial liquidity to receive LP tokens
- Lock LP tokens using
lockTokensto receive LOCKED SFT - Send LOCKED SFT to Router's
setSwapEnabledByUserto activate swaps - Router validates and returns the SFT to the user
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:
- User sends tokens as payment along with the unlock epoch
- Contract validates the unlock epoch is in the future
- Tokens are locked and LOCKED SFT is minted
- 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/jsonrequired
| scAddress required | string Simple Lock contract address |
| funcName required | string Value: "lockTokens" |
| args required | Array of strings Arguments:
|
| value required | string Token payment to lock |
Responses
Request samples
- Payload
{- "scAddress": "klv1qqqqqqqqqqqqqpgq9696g7x76kwrrh02fahn4rpem4v595t8c0nqgxzpmu",
- "funcName": "lockTokens",
- "args": [
- "u64:100"
], - "value": "KFIKLVLP-2GC1=1000000"
}Response samples
- 200
{- "data": {
- "returnData": [
- "string"
], - "returnCode": "string",
- "returnMessage": "string"
}, - "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:
- User sends LOCKED SFT as payment
- Contract verifies the current epoch is >= unlock epoch
- LOCKED SFT is burned
- 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/jsonrequired
| scAddress required | string Simple Lock contract address |
| funcName required | string Value: "unlockTokens" |
| args | Array of strings Arguments:
|
| value required | string LOCKED SFT payment |
Responses
Request samples
- Payload
{- "scAddress": "klv1qqqqqqqqqqqqqpgq9696g7x76kwrrh02fahn4rpem4v595t8c0nqgxzpmu",
- "funcName": "unlockTokens",
- "args": [ ],
- "value": "LOCK-2U1O/1=1000000"
}Response samples
- 200
{- "data": {
- "returnData": [
- "string"
], - "returnCode": "string",
- "returnMessage": "string"
}, - "error": "string",
- "code": "string"
}