SolScript
Write Solidity. Deploy to Solana.
SolScript lets you write smart contracts in familiar Solidity syntax and compile them to native Solana programs. No Rust required. No Anchor boilerplate. Just your contract logic.
contract Token {
mapping(address => uint256) public balanceOf;
function transfer(address to, uint256 amount) public {
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
emit Transfer(msg.sender, to, amount);
}
}
This compiles to a fully functional Solana program with automatic PDA derivation, account validation, and Anchor compatibility.
Why SolScript?
| Challenge | SolScript Solution |
|---|---|
| Rust learning curve | Write in Solidity syntax you already know |
| Anchor boilerplate | Auto-generated account structs and constraints |
| PDA complexity | mapping automatically becomes PDAs |
| Account validation | Derived from your contract's type system |
| Ecosystem lock-in | Output is standard Anchor/Rust - eject anytime |
Before: Raw Anchor (70+ lines)
use *;
// ... plus error definitions, events, account structs
After: SolScript (12 lines)
contract Token {
mapping(address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 value);
error InsufficientBalance();
function transfer(address to, uint256 amount) public {
if (balanceOf[msg.sender] < amount) revert InsufficientBalance();
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
emit Transfer(msg.sender, to, amount);
}
}
Quick Start
# Install
# Create a project
# Build and deploy
What You Can Build
SolScript supports the contract patterns you need for real DeFi and NFT applications:
Tokens & DeFi
contract AMM {
mapping(address => uint256) public reserves;
function swap(address tokenIn, address tokenOut, uint256 amountIn) public {
uint256 amountOut = getAmountOut(amountIn, reserves[tokenIn], reserves[tokenOut]);
Token(tokenIn).transferFrom(msg.sender, address(this), amountIn);
Token(tokenOut).transfer(msg.sender, amountOut);
reserves[tokenIn] += amountIn;
reserves[tokenOut] -= amountOut;
}
}
Escrow & Marketplaces
contract Escrow {
enum State { Funded, Released, Refunded, Disputed }
struct Deal {
address buyer;
address seller;
uint256 amount;
State state;
}
mapping(uint256 => Deal) public deals;
function release(uint256 dealId) public {
Deal storage deal = deals[dealId];
require(msg.sender == deal.buyer);
require(deal.state == State.Funded);
deal.state = State.Released;
transfer(deal.seller, deal.amount);
}
}
Access Control
contract Governed {
address public owner;
bool public paused;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier whenNotPaused() {
require(!paused);
_;
}
function pause() public onlyOwner {
paused = true;
}
}
Features
| Feature | Status |
|---|---|
| State variables (primitives, structs, arrays) | Supported |
| Mappings to PDA transformation | Supported |
| Nested mappings | Supported |
| Events and custom errors | Supported |
| Access control modifiers | Supported |
| View/pure functions | Supported |
| Cross-program invocation (CPI) | Supported |
| SPL Token operations | Supported |
| Direct SOL transfers | Supported |
msg.sender, block.timestamp |
Supported |
| Structs and enums | Supported |
Compilation Modes
Anchor Mode (Default)
Generates Rust/Anchor code, then compiles with cargo build-sbf. Full Anchor ecosystem compatibility.
Direct LLVM Mode
Compiles directly to BPF bytecode via LLVM. Faster iteration, smaller output.
Requires LLVM 18:
# Ubuntu/Debian
# macOS
CLI Reference
IDE Support
VS Code Extension with full language server support:
- Syntax highlighting
- Go to definition
- Autocomplete
- Inline error diagnostics
- Hover documentation
&& &&
Examples
| Example | Description |
|---|---|
| counter | Simple state management |
| token | ERC20-style fungible token |
| escrow | Multi-party trustless escrow |
| voting | On-chain governance |
| nft | NFT minting and transfers |
| staking | Token staking with rewards |
| amm | Automated market maker |
How It Works
┌─────────────────┐
│ Solidity-like │
│ Source Code │
└────────┬────────┘
│ parse
┌────────▼────────┐
│ AST │
└────────┬────────┘
│ type check
┌────────▼────────┐
│ Typed AST │
└────────┬────────┘
│
┌────┴────┐
│ │
┌───▼───┐ ┌───▼───┐
│Anchor │ │ LLVM │
│Codegen│ │Codegen│
└───┬───┘ └───┬───┘
│ │
┌───▼───┐ ┌───▼───┐
│ Rust │ │ BPF │
│Source │ │Bytecode│
└───┬───┘ └───────┘
│
┌───▼────────┐
│cargo build-│
│ sbf │
└───┬────────┘
│
┌───▼───┐
│ .so │
│Program│
└───────┘
Documentation
Internal dev docs: docs/ - Language spec, roadmap, design decisions
Current Limitations
| Limitation | Notes |
|---|---|
No msg.value for incoming SOL |
Use wrapped SOL or explicit transfer |
| No Token 2022 | Coming in v0.4 |
| Modifiers are inlined | Keep modifiers small |
Contributing
We welcome contributions. Priority areas:
- Parser grammar extensions
- Token 2022 CPI generation
- Integration tests
- Documentation improvements
See docs/ for internal development documentation.
License
MIT License - see LICENSE
SolScript: Solidity syntax. Solana performance. Ship faster.