sunsail

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: Apache-2.0

README

SunSail

SunSail

A minimalist, ultra-fast smart-contract development framework for the TRON network, written entirely in Go. One static binary — sun — replaces the JavaScript tooling with a Foundry-inspired workflow: compilation, Solidity-native testing on a real TVM interpreter, deployment scripting with exact costs, energy estimation against live network state, and security auditing.

CI

License: Apache-2.0.

Why

  • One binary, zero runtime dependencies. CGO_ENABLED=0, statically linked, cross-compiled for linux/darwin/windows. No Node, no npm. Windows builds are cross-compiled and unit-tested but not CI-executed (see docs/CI.md).
  • A real TVM, not an EVM approximation. The built-in interpreter implements TRON's divergences — the two-layer energy model, TRON's SSTORE pricing, the exact precompile transforms, 0x41 address derivation, call depth 64, TIP-6780 — and its metering is validated ±0 against java-tron on Nile (no tolerances; see docs/TVM.md).
  • Real transactions, not simulations. On TRON a deployment address derives from the transaction id, so sun script builds the actual signed transaction sequence — tx N's txid feeds tx N+1's addresses — and the planned costs equal the on-chain receipts exactly.
  • Trust through verification. External binaries (solc-tron, aderyn) are version-pinned and SHA-256-verified before they ever execute. Where the node contradicts the documentation, the node wins and the discrepancy is recorded (see the Errata section of docs/ARCHITECTURE.md).

Install

With Go 1.26+ installed, the fastest path is go install:

go install github.com/sailor-labs/sunsail/cmd/sun@latest

Or grab a prebuilt static binary for your platform from the Releases page (available since v0.1.0; verify it against the published SHA256SUMS).

Or build from source (requires Go 1.26+):

git clone https://github.com/sailor-labs/sunsail
cd sunsail
make build            # ./out/sun for the host platform
make release          # 6-platform static matrix + SHA256SUMS

Commands

Command What it does Example
sun init Scaffold a Foundry-like project from embedded templates sun init my-project
sun compile Incremental, deterministic compilation with a pinned solc-tron sun compile
sun test Run Solidity tests (test/*.t.sol) on the local TVM, with cheatcodes and source-mapped traces; optionally over the live state of a network sun test -vvv --fork-url nile
sun estimate Exact Energy / Bandwidth / TRX-burn figures for a call to an already-deployed contract sun estimate TMts7FK5h5US99x16qCRkJUzd1VYtahd7o "sail(uint256)" 5 --network nile
sun script Plan (and optionally broadcast) a deployment script as a real transaction sequence with per-tx costs sun script script/Deploy.s.sol --network nile --broadcast
sun audit Aderyn static analysis with TVM-aware per-file degradation sun audit --fail-on high
sun sonar Utilities: address conversion, selectors, CREATE2 derivation sun sonar address TR7NHq...

sun estimate reports the cost of calling a contract that is already deployed on the network — it needs the contract's on-chain address. To estimate a call to your own contract, deploy it first (e.g. with sun script --broadcast), then pass its address.

The typical end-to-end flow:

sun init dapp && cd dapp
sun compile
sun test -v
sun script script/Deploy.s.sol --network nile --broadcast   # deploy first
sun estimate <deployed-address> "sail(uint256)" 5 --network nile
sun audit

Naming, quickly

  • sun is the binary (TRX's smallest unit is also called sun — that is the pun, embrace it).
  • sail.toml is the project configuration: pinned compiler + checksums, network endpoints, the audit binary pin. See docs/CONFIG.md.
  • sail.sol is the embedded cheatcode interface available to tests (sail.prank(...), sail.deal(...), sail.expectRevert(), ...). See docs/TESTING.md.

Networks

sail.toml declares each network's three endpoints — the FullNode gRPC service (broadcast), the Solidity gRPC service (irreversible confirmation), and a JSON-RPC endpoint used only by the fork storage reader. The scaffold ships mainnet and nile (the public test network) preconfigured. Develop against Nile first; sun script requires an explicit --broadcast before anything leaves your machine, and the signing key is only ever read from the PRIVATE_KEY environment variable or the project's git-ignored .env.

Documentation

Deep references live in docs/:

  • ARCHITECTURE.md — the source of truth: design, invariants, audit adjudications, and the errata log (E1–E5).
  • CONFIG.mdsail.toml schema and project layout.
  • COMPILER.md — the compilation pipeline and binary management.
  • TESTING.md — the test runner, cheatcodes, traces.
  • FORKING.md — the pinned-fork backend (sun test --fork-url).
  • SCRIPTING.md — the plan/broadcast model of sun script.
  • AUDIT.md — the audit pipeline and its TVM post-filter.
  • TVM.md — interpreter divergences, precompiles, energy model, and the differential validation results.
  • RPC.md / CRYPTO.md / BUILD.md — networking, signing, and build contracts.
  • CI.md — the three GitHub Actions workflows and the secrets the nightly needs.

Contributions welcome — see CONTRIBUTING.md. Security reports: SECURITY.md. Release history: CHANGELOG.md.

Directories

Path Synopsis
Package assets embeds SunSail's static Solidity and project assets into the binary (ARCHITECTURE §1.6), so a single `sun` executable needs no satellite files at runtime.
Package assets embeds SunSail's static Solidity and project assets into the binary (ARCHITECTURE §1.6), so a single `sun` executable needs no satellite files at runtime.
cmd
sun command
Command sun is the SunSail CLI: a single static binary for TRON smart-contract development.
Command sun is the SunSail CLI: a single static binary for TRON smart-contract development.
internal
abi
Package abi computes function selectors and encodes call arguments for the subset of ABI types that sun estimate and the S5 cheatcodes need.
Package abi computes function selectors and encodes call arguments for the subset of ABI types that sun estimate and the S5 cheatcodes need.
address
Package address converts between the two representations of a TRON address: Base58Check ("T..." — 34 characters) and 21-byte hex with the 0x41 prefix.
Package address converts between the two representations of a TRON address: Base58Check ("T..." — 34 characters) and 21-byte hex with the 0x41 prefix.
audit
Package audit runs Aderyn with controlled per-file degradation, a TVM rule post-filter, and multiple output formats.
Package audit runs Aderyn with controlled per-file degradation, a TVM rule post-filter, and multiple output formats.
cli
Package cli renders domain results to the terminal (raw ANSI or --json) and hosts the command implementations wired by cmd/sun.
Package cli renders domain results to the terminal (raw ANSI or --json) and hosts the command implementations wired by cmd/sun.
compiler
Package compiler drives solc-tron as the sole Solidity import resolver (ARCHITECTURE §5.2).
Package compiler drives solc-tron as the sole Solidity import resolver (ARCHITECTURE §5.2).
config
Package config resolves the cross-platform SAIL_HOME data directory (paths.go) and decodes the project's sail.toml with strict validation: unknown keys and type mismatches are errors carrying a line number, and every declared network must expose separate FullNode and Solidity gRPC endpoints (config.go).
Package config resolves the cross-platform SAIL_HOME data directory (paths.go) and decodes the project's sail.toml with strict validation: unknown keys and type mismatches are errors carrying a line number, and every declared network must expose separate FullNode and Solidity gRPC endpoints (config.go).
crypto
Package crypto performs secp256k1 signing and public-key recovery with the mandatory TRON format transform (ARCHITECTURE §5.1).
Package crypto performs secp256k1 signing and public-key recovery with the mandatory TRON format transform (ARCHITECTURE §5.1).
rpc
Package rpc owns all TRON network communication: gRPC-only, one ClientConn per (network, service Wallet|WalletSolidity), transaction construction byte rules, chain-parameter sourcing, and the EstimateEnergy capability fallback (ARCHITECTURE §5.4/§5.7).
Package rpc owns all TRON network communication: gRPC-only, one ClientConn per (network, service Wallet|WalletSolidity), transaction construction byte rules, chain-parameter sourcing, and the EstimateEnergy capability fallback (ARCHITECTURE §5.4/§5.7).
rpc/rpctest
Package rpctest provides an in-process gRPC server implementing the protocol.Wallet and protocol.WalletSolidity services with programmable responses.
Package rpctest provides an in-process gRPC server implementing the protocol.Wallet and protocol.WalletSolidity services with programmable responses.
runner
Package runner discovers *.t.sol tests, dispatches cheatcodes, and produces deterministic output over a worker pool.
Package runner discovers *.t.sol tests, dispatches cheatcodes, and produces deterministic output over a worker pool.
scaffold
Package scaffold materializes a new SunSail project from the embedded templates (the `sun init` command).
Package scaffold materializes a new SunSail project from the embedded templates (the `sun init` command).
script
Package script builds a full sequential transaction plan (txid-derived CREATE addresses) and broadcasts it under a confirmation policy.
Package script builds a full sequential transaction plan (txid-derived CREATE addresses) and broadcasts it under a confirmation policy.
state
Package state provides StateDB backends: an in-memory backend for pure tests (this file) and, from S6 on, a pinned-fork backend (lazy gRPC fetch, LRU, singleflight).
Package state provides StateDB backends: an in-memory backend for pure tests (this file) and, from S6 on, a pinned-fork backend (lazy gRPC fetch, LRU, singleflight).
tvm
Package tvm implements the TRON Virtual Machine interpreter, exact precompiles, CREATE/CREATE2 derivation, and basic energy metering.
Package tvm implements the TRON Virtual Machine interpreter, exact precompiles, CREATE/CREATE2 derivation, and basic energy metering.
test
e2e
Package e2e holds the end-to-end harness: it builds the real sun binary and drives full command flows via os/exec in a temporary directory.
Package e2e holds the end-to-end harness: it builds the real sun binary and drives full command flows via os/exec in a temporary directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL