functions
Complete reference for all frontend JavaScript functions in the veCUBE rewards UI.
connectWallet()
connectWallet()Connects the user's injected wallet and switches to Monad Mainnet.
Flow:
Error handling:
4001
User rejected
Show toast, log warning
4902
Chain not added
Auto-add Monad network
-32603
Internal RPC error
Attempt chain add
loadNFTs()
loadNFTs()Scans the full CubeNFT collection for tokens owned by the connected wallet.
Flow:
Calls balanceOf(wallet) and totalMinted() in parallel
Iterates token IDs 1..totalMinted in batches of 20
Uses Promise.allSettled — failed RPC calls don't abort the scan
For each token: calls ownerOf(id) → if matched, calls getCubeData(id)
Renders NFTs progressively as each batch resolves
Stops early once balance count is satisfied
renderNFTs(nfts)
renderNFTs(nfts)Renders the scanned NFT array into the grid panel as clickable cards.
Parameter: nfts — Array<{ id: number, ci: number, sym: string }>
Each card displays:
Colored SVG hexagon (color from
colorIndex % 8)Token ID formatted as
#001Coin symbol (e.g.
PEPE)"tap to select" hint
Color palette:
0
#39ff14 (green)
1
#ff2244 (red)
2
#ffe600 (yellow)
3
#bb99ff (purple)
4
#ff6b35 (orange)
5
#00ccff (cyan)
6
#ff88cc (pink)
7
#88ffcc (mint)
pick(id, sym)
pick(id, sym)Selects an NFT card and auto-populates the Claim form.
Parameters:
id— Token ID (number)sym— Coin symbol string
Actions:
Removes
.selclass from all NFT cardsAdds
.selto clicked card (green border + glow)Sets the Token ID input field value
Calls
calcRewards()to fetch pending amounts
calcRewards()
calcRewards()Fetches pending reward amounts for the selected veCube contract + token ID.
Reads: Rewards.pendingRewards(veCube, tokenId) via read-only provider
Separates CUBE and BMC amounts by matching token addresses against:
ADDR.cube=0x87Bdd0E32aca3AC42d5D35baF38937Eae840f5A3ADDR.bmc=0x244DF0E3A8276aDD749AF3ec3Ff7e642B1dC46a5
Displays:
CUBE amount (18 decimals) + USD value at
$0.001BMC amount (18 decimals) + USD value at
$0.05
On error: Shows 0 and (epoch active) — epoch is still running.
claimRewards()
claimRewards()Submits the claimAll() transaction for the selected veCube + token ID.
Pre-checks:
Wallet connected (calls
connectWallet()if not)veCube contract and token ID selected
currentEpoch() > 0(Epoch 0 is not claimable yet)
Transaction:
Button states during tx:
initRead()
initRead()Initializes read-only JsonRpcProvider on page load. No wallet required.
Reads:
CubeNFT.totalMinted()→ updates Total Minted statRewards.currentEpoch()→ updates Epoch stat and timer
tick()
tick()Updates the epoch countdown timer every second via setInterval.
Calculates:
Time remaining until
2026-03-31T00:00:00ZProgress percentage:
(now - MAR_01) / (MAR_31 - MAR_01) × 100
Updates: Days, hours, minutes, seconds digits + progress bar + percentage label.
log(msg, cls)
log(msg, cls)Appends a timestamped line to the terminal panel.
msg
Any string
—
cls
'ok' (green), 'er' (red), 'wn' (yellow)
'ok'
Auto-scrolls terminal to latest entry.
toast(msg)
toast(msg)Displays a brief notification at the bottom center of the screen. Auto-dismisses after 3.5 seconds.
cp(addr)
cp(addr)Copies a contract address to the clipboard and shows a confirmation toast. Used by the Contracts panel.
Was this helpful?
