Get up and running with SolScript in minutes.
solscript new my-project
cd my-projectThis creates a new project using the default template (counter):
my-project/
├── src/
│ └── main.sol # Your contract
├── solscript.toml # Project configuration
├── .gitignore
└── README.md
SolScript includes templates for common patterns:
# List available templates
solscript new --list
# Create with a specific template
solscript new my-token --template token
solscript new my-nft --template nftAvailable templates:
| Template | Difficulty | Description |
|---|---|---|
simple |
Beginner | Minimal contract for learning |
counter |
Beginner | Counter with ownership (default) |
token |
Intermediate | ERC20-style fungible token |
voting |
Intermediate | Decentralized voting system |
escrow |
Advanced | Trustless escrow with disputes |
nft |
Advanced | ERC721-style NFT collection |
[project]
name = "my-project"
version = "0.1.0"
[contract]
main = "src/main.sol"
name = "MyProject"
[build]
output = "output"
[solana]
cluster = "devnet"
[dependencies]
# Add packages hereThe generated contract template:
contract MyProject {
@state counter: u64;
@state owner: Address;
event CounterIncremented(by: Address, newValue: u64);
fn init() {
self.owner = tx.sender;
self.counter = 0;
}
@public
fn increment() {
self.counter += 1;
emit CounterIncremented(tx.sender, self.counter);
}
@public
@view
fn get_counter(): u64 {
return self.counter;
}
}
solscript check src/main.solsolscript build src/main.solThis creates an Anchor project in output/:
output/
├── Anchor.toml
├── Cargo.toml
├── programs/
│ └── solscript_program/
│ └── src/
│ ├── lib.rs
│ ├── state.rs
│ ├── instructions.rs
│ ├── error.rs
│ └── events.rs
└── tests/
Via Anchor (default):
solscript build-bpf src/main.solVia Direct LLVM (faster, requires LLVM 18):
solscript build-bpf --llvm src/main.solThis compiles to a deployable Solana program (.so file).
Automatically rebuild on file changes:
solscript watch src/main.solsolscript fmt src/main.solAdd test functions to your contract:
contract MyProject {
// ... contract code ...
#[test]
fn test_increment() {
increment();
assert_eq(self.counter, 1, "Counter should be 1");
}
}
Run tests:
solscript test src/main.solStart a local validator:
solana-test-validatorDeploy:
solscript deploy src/main.sol --cluster localnet# Ensure you have devnet SOL
solana airdrop 2 --url devnet
# Deploy
solscript deploy src/main.sol --cluster devnet| Command | Description |
|---|---|
solscript new <name> |
Create new project from template |
solscript new --list |
List available templates |
solscript check <file> |
Type check only |
solscript build <file> |
Generate Anchor code |
solscript build-bpf <file> |
Compile to BPF (via Anchor) |
solscript build-bpf --llvm <file> |
Compile to BPF (direct LLVM) |
solscript test <file> |
Run tests |
solscript deploy <file> |
Deploy to cluster |
solscript watch <file> |
Watch and rebuild |
solscript fmt <file> |
Format code |
solscript doctor |
Check environment |
solscript lsp |
Start Language Server |
- Your First Contract - Learn contract basics
- Language Guide - Deep dive into SolScript
- Examples - Browse example contracts