Overview
WLABS (Wrapped LABS) is an ERC-20 token that wraps the native LABS token, following the WETH9 pattern. This allows native LABS to be used in smart contracts that require ERC-20 tokens, such as the TrustVault staking contract. The contract maintains a 1:1 peg with native LABS and supports both explicit deposit() calls and automatic wrapping via the receive() function.
**Note: Deployed Address: 0xEd863CAd86f69D8821f678784c5a47d21626BBF7
Token Details
- Name: Wrapped LABS
- Symbol: WLABS
- Decimals: 18
- Total Supply: Equals the contract's native LABS balance (dynamic)
Functions
| Function | Parameters | Returns | Description |
|---|---|---|---|
deposit | - (payable) | - | Wrap native LABS to WLABS (send LABS with transaction) |
withdraw | uint256 wad | - | Unwrap WLABS to native LABS (must have WLABS balance) |
balanceOf | address | uint256 | Get WLABS balance of an address (ERC-20 standard) |
approve | address guy, uint256 wad | bool | Approve another address to spend WLABS (ERC-20 standard) |
transfer | address dst, uint256 wad | bool | Transfer WLABS to another address (ERC-20 standard) |
transferFrom | address src, address dst, uint256 wad | bool | Transfer WLABS from one address to another (ERC-20 standard) |
totalSupply | - | uint256 | Get total WLABS supply (equals contract LABS balance) |
allowance | address owner, address spender | uint256 | Get approved spending amount (ERC-20 standard) |
Special Behavior
The contract implements a receive() function that automatically calls deposit() when native LABS are sent directly to the contract address. This means you can wrap LABS by simply sending it to the WLABS contract.
Events
| Event | Parameters | Description |
|---|---|---|
Deposit | address indexed dst, uint256 wad | Emitted when LABS are wrapped to WLABS |
Withdrawal | address indexed src, uint256 wad | Emitted when WLABS are unwrapped to LABS |
Transfer | address indexed src, address indexed dst, uint256 wad | Emitted on WLABS transfers (ERC-20 standard) |
Approval | address indexed src, address indexed guy, uint256 wad | Emitted when spending approval is set (ERC-20 standard) |
Usage Example
import { createPublicClient, createWalletClient, http, parseAbi, parseEther } from 'viem';
import { kyaChain } from './chains';
const publicClient = createPublicClient({
chain: kyaChain,
transport: http('https://rpc.kyachain.xyz'),
});
const walletClient = createWalletClient({
chain: kyaChain,
transport: http('https://rpc.kyachain.xyz'),
});
const WLABS = '0xEd863CAd86f69D8821f678784c5a47d21626BBF7';
// Method 1: Wrap LABS using deposit() function
const { request: depositReq } = await publicClient.simulateContract({
address: WLABS,
abi: parseAbi(['function deposit() external payable']),
functionName: 'deposit',
value: parseEther('1000'), // Send 1,000 LABS
account: '0xYourAddress',
});
const depositHash = await walletClient.writeContract(depositReq);
await publicClient.waitForTransactionReceipt({ hash: depositHash });
// Method 2: Wrap LABS by sending directly to contract (uses receive() function)
const sendHash = await walletClient.sendTransaction({
to: WLABS,
value: parseEther('1000'),
account: '0xYourAddress',
});
// Check WLABS balance
const balance = await publicClient.readContract({
address: WLABS,
abi: parseAbi(['function balanceOf(address) external view returns (uint256)']),
functionName: 'balanceOf',
args: ['0xYourAddress'],
});
console.log('WLABS balance:', balance); // 1000000000000000000000n (1000 WLABS)
// Approve TrustVault to spend WLABS (required before staking)
const TRUST_VAULT = '0xD4bAE271bCCb8bA7BF13B0B4743d62E61CCF9E0e';
const { request: approveReq } = await publicClient.simulateContract({
address: WLABS,
abi: parseAbi(['function approve(address guy, uint256 wad) external returns (bool)']),
functionName: 'approve',
args: [TRUST_VAULT, parseEther('10000')],
account: '0xYourAddress',
});
const approveHash = await walletClient.writeContract(approveReq);
// Unwrap WLABS back to native LABS
const { request: withdrawReq } = await publicClient.simulateContract({
address: WLABS,
abi: parseAbi(['function withdraw(uint256 wad) external']),
functionName: 'withdraw',
args: [parseEther('500')], // Unwrap 500 WLABS
account: '0xYourAddress',
});
const withdrawHash = await walletClient.writeContract(withdrawReq);
// Transfer WLABS to another address
const { request: transferReq } = await publicClient.simulateContract({
address: WLABS,
abi: parseAbi(['function transfer(address dst, uint256 wad) external returns (bool)']),
functionName: 'transfer',
args: ['0xRecipientAddress', parseEther('100')],
account: '0xYourAddress',
});
const transferHash = await walletClient.writeContract(transferReq);ABI
[
"function deposit() external payable",
"function withdraw(uint256 wad) external",
"function balanceOf(address) external view returns (uint256)",
"function approve(address guy, uint256 wad) external returns (bool)",
"function transfer(address dst, uint256 wad) external returns (bool)",
"function transferFrom(address src, address dst, uint256 wad) external returns (bool)",
"function totalSupply() external view returns (uint256)",
"function allowance(address owner, address spender) external view returns (uint256)",
"event Deposit(address indexed dst, uint256 wad)",
"event Withdrawal(address indexed src, uint256 wad)",
"event Transfer(address indexed src, address indexed dst, uint256 wad)",
"event Approval(address indexed src, address indexed guy, uint256 wad)"
]