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:
- Writea script in any language Weft speaks
- Weavethe SDK compiles it to Weft bytecode, offline
- Postinline in the instruction, or once to a script account
- Runthe Weft program interprets it op by op, metered in compute units
- Returnlogs, return data and units used come back with the transaction
import { Weft } from '@weft/sdk'
const weft = new Weft({ connection, wallet })
const { value, logs, units } = await weft.run(`log("gm"); return 1 + 1`)