Skip to content
/ molt Public

A simple, secure STX vault on the Stacks blockchain. Users can deposit STX to earn safekeeping and withdraw their balance at any time. Built with Clarity for maximum transparency and security.

Notifications You must be signed in to change notification settings

kramu39/molt

Repository files navigation

Molt Vault 🏦

A simple, secure STX vault on the Stacks blockchain. Users can deposit STX to earn safekeeping and withdraw their balance at any time. Built with Clarity for maximum transparency and security.

Live on Stacks Testnet
Contract Address: SP29VJHHXFPRQMW6W1VDE9NVR4AZ04V44H3T1X01Y.molt-vault

Features

  • Deposit STX – Lock your STX in the vault
  • Withdraw STX – Retrieve your deposited STX anytime
  • Balance Tracking – Per-user balance stored on-chain
  • Zero Fees – No admin fees or withdrawal penalties
  • Secure Design – Transfers happen before state updates (reentrancy-safe)
  • No Owner Privileges – Fully permissionless after deployment

Quick Start (Interact with the Deployed Contract)

Use the Hiro Explorer Sandbox to test instantly:

  1. Go to: https://explorer.hiro.so/sandbox/contract-call?chain=testnet
  2. Connect your wallet (Testnet mode)
  3. Contract address: SP29VJHHXFPRQMW6W1VDE9NVR4AZ04V44H3T1X01Y.molt-vault

Deposit

  • Function: deposit
  • Arguments: amount (uint) – e.g., 1000000 (1 STX = 1,000,000 microSTX)
  • Attach STX equal to the amount

Withdraw

  • Function: withdraw
  • Arguments: amount (uint) – amount to withdraw
  • Receives STX directly to your wallet

Check Balance

  • Read-only function: get-balance
  • Arguments: user (principal) – your wallet address
  • Returns your current balance

Contract Code

(define-map balances principal uint)

(define-constant err-insufficient-balance (err u101))
(define-constant err-zero-amount (err u102))
(define-constant contract-principal 'SP29VJHHXFPRQMW6W1VDE9NVR4AZ04V44H3T1X01Y.molt-vault)

(define-public (deposit (amount uint))
  (begin
    (asserts! (> amount u0) err-zero-amount)
    (try! (stx-transfer? amount tx-sender contract-principal))
    (ok (map-set balances
                 tx-sender
                 (+ (default-to u0 (map-get? balances tx-sender)) amount)))
  )
)

(define-public (withdraw (amount uint))
  (let ((sender tx-sender)
        (current (default-to u0 (map-get? balances sender))))
    (asserts! (> amount u0) err-zero-amount)
    (asserts! (>= current amount) err-insufficient-balance)
    (try! (stx-transfer? amount contract-principal sender))
    (ok (map-set balances sender (- current amount)))
  )
)

(define-read-only (get-balance (user principal))
  (ok (default-to u0 (map-get? balances user)))
)

Local Development

Prerequisites

Setup

clarinet new molt-vault
cd molt-vault
# Replace contracts/molt-vault.clar with the code above

Test

clarinet test

Deploy to Testnet (CLI)

clarinet deployment generate --testnet
clarinet deployment apply --testnet

Or use the Hiro Explorer Sandbox for quick deploys.

Future Ideas

  • Add yield farming integration
  • Support SIP-010 tokens
  • Admin pause/emergency withdraw
  • Events for deposits/withdrawals

Disclaimer

This is a simple educational vault deployed on testnet. Use at your own risk. For production use, consider audits and additional safeguards.

License

MIT License – feel free to fork and build on it!

Built with ❤️ in Nairobi by Sheila

About

A simple, secure STX vault on the Stacks blockchain. Users can deposit STX to earn safekeeping and withdraw their balance at any time. Built with Clarity for maximum transparency and security.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published