DocsIntroduction

Introduction

Weft is one program on Solana that interprets Weft bytecode inside the Solana VM. Every language Weft speaks compiles to that bytecode, so a script written in JavaScript, Python, Lua or Lisp runs on-chain without a program of its own.

A script reads and writes accounts, keeps its own storage, moves lamports, logs, and returns a value. A run is five steps:

  1. Writea script in any language Weft speaks
  2. Weavethe SDK compiles it to Weft bytecode, offline
  3. Postinline in the instruction, or once to a script account
  4. Runthe Weft program interprets it op by op, metered in compute units
  5. Returnlogs, return data and units used come back with the transaction
TypeScript · @weft/sdk
import { Weft } from '@weft/sdk'

const weft = new Weft({ connection, wallet })
const { value, logs, units } = await weft.run(`log("gm"); return 1 + 1`)