| Crates.io | solscript-codegen |
| lib.rs | solscript-codegen |
| version | 0.1.1 |
| created_at | 2026-01-19 23:31:37.355716+00 |
| updated_at | 2026-01-19 23:31:37.355716+00 |
| description | Rust/Anchor code generator for SolScript smart contracts |
| homepage | https://github.com/cryptuon/solscript |
| repository | https://github.com/cryptuon/solscript |
| max_upload_size | |
| id | 2055510 |
| size | 226,318 |
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.
| 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 |
use anchor_lang::prelude::*;
#[program]
pub mod token {
pub fn transfer(ctx: Context<Transfer>, amount: u64) -> Result<()> {
let from = &mut ctx.accounts.from_balance;
let to = &mut ctx.accounts.to_balance;
require!(from.amount >= amount, TokenError::InsufficientBalance);
from.amount -= amount;
to.amount += amount;
emit!(TransferEvent { from: ctx.accounts.from.key(), to: ctx.accounts.to.key(), amount });
Ok(())
}
}
#[derive(Accounts)]
pub struct Transfer<'info> {
#[account(mut)]
pub from: Signer<'info>,
#[account(mut, seeds = [b"balance", from.key().as_ref()], bump)]
pub from_balance: Account<'info, Balance>,
#[account(mut, seeds = [b"balance", to.key().as_ref()], bump)]
pub to_balance: Account<'info, Balance>,
/// CHECK: recipient
pub to: AccountInfo<'info>,
pub system_program: Program<'info, System>,
}
// ... plus error definitions, events, account structs
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);
}
}
# Install
cargo install --git https://github.com/cryptuon/solscript solscript-cli
# Create a project
solscript init my-token
cd my-token
# Build and deploy
solscript build-bpf
solana program deploy target/deploy/my_token.so
SolScript supports the contract patterns you need for real DeFi and NFT applications:
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;
}
}
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);
}
}
contract Governed {
address public owner;
bool public paused;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier whenNotPaused() {
require(!paused);
_;
}
function pause() public onlyOwner {
paused = true;
}
}
| 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 |
Generates Rust/Anchor code, then compiles with cargo build-sbf. Full Anchor ecosystem compatibility.
solscript build-bpf contract.sol
Compiles directly to BPF bytecode via LLVM. Faster iteration, smaller output.
solscript build-bpf --llvm contract.sol
Requires LLVM 18:
# Ubuntu/Debian
sudo apt install llvm-18-dev
export LLVM_SYS_180_PREFIX=/usr/lib/llvm-18
# macOS
brew install llvm@18
export LLVM_SYS_180_PREFIX=$(brew --prefix llvm@18)
solscript init <name> # Create new project
solscript build <file> # Generate Rust/Anchor code
solscript build-bpf <file> # Compile to deployable .so
solscript build-bpf --llvm # Direct LLVM compilation
solscript check <file> # Type check (fast feedback)
solscript test # Run tests
solscript fmt <file> # Format code
solscript lsp # Start language server
VS Code Extension with full language server support:
cd vscode-extension && npm install && npm run package
code --install-extension solscript-*.vsix
| 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 |
┌─────────────────┐
│ Solidity-like │
│ Source Code │
└────────┬────────┘
│ parse
┌────────▼────────┐
│ AST │
└────────┬────────┘
│ type check
┌────────▼────────┐
│ Typed AST │
└────────┬────────┘
│
┌────┴────┐
│ │
┌───▼───┐ ┌───▼───┐
│Anchor │ │ LLVM │
│Codegen│ │Codegen│
└───┬───┘ └───┬───┘
│ │
┌───▼───┐ ┌───▼───┐
│ Rust │ │ BPF │
│Source │ │Bytecode│
└───┬───┘ └───────┘
│
┌───▼────────┐
│cargo build-│
│ sbf │
└───┬────────┘
│
┌───▼───┐
│ .so │
│Program│
└───────┘
Internal dev docs: docs/ - Language spec, roadmap, design decisions
| 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 |
We welcome contributions. Priority areas:
See docs/ for internal development documentation.
MIT License - see LICENSE
SolScript: Solidity syntax. Solana performance. Ship faster.