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
- 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
Use the Hiro Explorer Sandbox to test instantly:
- Go to: https://explorer.hiro.so/sandbox/contract-call?chain=testnet
- Connect your wallet (Testnet mode)
- Contract address:
SP29VJHHXFPRQMW6W1VDE9NVR4AZ04V44H3T1X01Y.molt-vault
- Function:
deposit - Arguments:
amount(uint) – e.g.,1000000(1 STX = 1,000,000 microSTX) - Attach STX equal to the amount
- Function:
withdraw - Arguments:
amount(uint) – amount to withdraw - Receives STX directly to your wallet
- Read-only function:
get-balance - Arguments:
user(principal) – your wallet address - Returns your current balance
(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)))
)- Install Clarinet
clarinet new molt-vault
cd molt-vault
# Replace contracts/molt-vault.clar with the code aboveclarinet testclarinet deployment generate --testnet
clarinet deployment apply --testnetOr use the Hiro Explorer Sandbox for quick deploys.
- Add yield farming integration
- Support SIP-010 tokens
- Admin pause/emergency withdraw
- Events for deposits/withdrawals
This is a simple educational vault deployed on testnet. Use at your own risk. For production use, consider audits and additional safeguards.
MIT License – feel free to fork and build on it!
Built with ❤️ in Nairobi by Sheila