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 counter template (solscript new default) is real Solidity:
contract Counter {
uint256 public count;
address public owner;
event Incremented(address indexed by, uint256 newValue);
event Decremented(address indexed by, uint256 newValue);
event Reset(address indexed by);
error Underflow();
error Unauthorized();
modifier onlyOwner() {
if (msg.sender != owner) revert Unauthorized();
_;
}
constructor() {
owner = msg.sender;
count = 0;
}
function increment() public {
count += 1;
emit Incremented(msg.sender, count);
}
function decrement() public {
if (count == 0) revert Underflow();
count -= 1;
emit Decremented(msg.sender, count);
}
function reset() public onlyOwner {
count = 0;
emit Reset(msg.sender);
}
function getCount() public view returns (uint256) {
return count;
}
}Other available templates: simple, token, voting, escrow, nft.
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