Slvr Smart Contract Language

Complete guide to Slvr: syntax, built-in functions, and best practices

Language Overview

Slvr is a production-ready smart contract language with:

Basic Syntax

Functions

(defun hello (name)
  "Greet someone"
  (+ "Hello, " name "!")
)

(defun add (a b)
  "Add two numbers"
  (+ a b)
)

Variables

(let ((x 10)
      (y 20))
  (+ x y)
)

Conditionals

(if (> x 10)
  "x is greater than 10"
  "x is less than or equal to 10"
)

Built-in Functions

String Functions

Math Functions

List Functions

Cryptographic Functions

Type System

Basic Types

Linear Types

Linear types prevent resource duplication:

(defun transfer (from to amount)
  "Transfer tokens (linear type ensures no duplication)"
  (let ((balance (get-balance from)))
    (if (>= balance amount)
      (do
        (set-balance from (- balance amount))
        (set-balance to (+ (get-balance to) amount))
        true
      )
      false
    )
  )
)

Fuel Metering

All operations have deterministic costs:

Best Practices

Ready to build?

Getting StartedAPI Reference