Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Deploy Your First C Program on Thru Alphanet

๐Ÿ‡ฎ๐Ÿ‡ฉ Baca dalam Bahasa Indonesia: README.id.md ยท ๐Ÿ‡ฌ๐Ÿ‡ง Read in English: README.md

This README is a complete, step-by-step tutorial: by the end you will have a 138-byte C program compiled to RISC-V, deployed to the public Thru alphanet, and executed on-chain โ€” verifiable in a public explorer. It takes about one afternoon, and it costs nothing: the alphanet faucet funds everything. Every command, output, address, and signature below comes from a real end-to-end session run on 8 July 2026 โ€” nothing is mocked or approximated.

Proof that this works:

Program account taoXfGFJWJi0CdC_IxEebrZoHJIGLSPjfZsdQBDdhqodsr
First execution tsk4tEmApwurhGodqw-u55M_dZX_PlL6hmzLA3fnZjKyjIjfYTu_QxgUq1q-6frgps7xtVKwnL63pq-uZweF3QDyJX
Binary size 138 bytes (flat ThruVM binary, not ELF)
Toolchain thru CLI 0.2.38+8eb269bd ยท riscv64-unknown-elf-gcc (g5115c7e44) 15.2.0

What is Thru?

Thru is a high-performance L1 built by Unto Labs, a San Francisco team founded in late 2024 by Liam Heeger (previously Solana core and Jump Crypto's Firedancer) and Will Yoo. The company raised $14.4M in April 2025 โ€” a pre-seed from Framework Ventures plus a seed from Electric Capital. The part that matters for developers is ThruVM: a RISC-V virtual machine (RV64IMCB+Zknh) that executes programs written in plain C โ€” no DSL, no custom language, just a compiler and a Makefile. The alphanet is live and public: the CLI talks to https://rpc.alphanet.thru.org by default with zero configuration, a faucet hands out test tokens for free, and there is an explorer at https://scan.thru.org. On security, the team announced on X (7 July 2026) that Neodyme audited the ThruVM runtime and OtterSec completed a second audit โ€” note the reports themselves have not been published, so this remains a team claim for now.

Prerequisites

  • A Linux x86_64 environment or a macOS Apple Silicon machine. This tutorial was verified on a Linux VPS (Ubuntu 24.04, x86_64); WSL2 on Windows works too.
  • Node.js and npm โ€” the CLI ships via npm.
  • build-essential (or at minimum make and gcc) and curl.
  • Disk space: the toolchain download alone is ~2.5 GB, so leave comfortable headroom.
  • No money. The faucet covers every fee in this tutorial.

Step 0 โ€” Windows users, read this first

The CLI itself installs and runs fine on Windows (npm i -g thru succeeds, thru getversion connects to alphanet). The build toolchain does not. In release v0.2.38 the toolchain assets ship only for Linux-x86_64 and Darwin-arm64, so on Windows thru dev toolchain install fails in one of two ways:

  • PowerShell: Error: Failed to detect OS: program not found โ€” the CLI shells out to uname, which plain Windows doesn't have.
  • Git Bash: uname exists there, so you get further, but then: Toolchain not found for MINGW64_NT-10.0-26200-x86_64 in release v0.2.38 โ€” there is simply no Windows toolchain build.

Fix: use WSL2 or a cheap Linux VPS. Everything below assumes Ubuntu 24.04 on x86_64.

Step 1 โ€” Install the CLI

npm i -g thru
thru getversion

Expected output: npm installs thru 0.2.38, and thru getversion connects to alphanet, reporting the node as thru-node 0.3.0-dev, thru-rpc sha-c469a59, status serving. The first run also silently creates ~/.thru/cli/config.yaml with a freshly generated default keypair.

โš ๏ธ Security warning: ~/.thru/cli/config.yaml stores your private key in plaintext. That is acceptable for a testnet key holding faucet tokens โ€” and nothing else. Never reuse this key or file for real funds. Testnet only.

Checkpoint: thru getversion returns node version info โ€” you are talking to alphanet with zero configuration.

Step 2 โ€” Install the toolchain and C SDK

thru dev toolchain install    # ~2.5 GB download โ€” takes a while
thru dev sdk install c        # ~1.6 MB, built & verified automatically

Expected output: the toolchain install downloads roughly 2.5 GB and took about 10 minutes in the verified session; it lands in ~/.thru/sdk/toolchain and ships riscv64-unknown-elf-gcc (g5115c7e44) 15.2.0. The C SDK install is quick and builds and verifies itself as part of the install.

๐Ÿ’ก Tip for SSH sessions: a dropped connection mid-download means starting over. Run the toolchain install under nohup or inside screen/tmux.

Checkpoint: the toolchain directory exists at ~/.thru/sdk/toolchain and the C SDK reports built and verified.

Step 3 โ€” Scaffold the project

thru dev init c hello-thru
cd hello-thru

Expected output: a new project containing a GNUmakefile, a Local.mk, and the program source at examples/hello_thru.c.

๐Ÿ“ฆ Cloning this repo instead? Skip thru dev init entirely โ€” this repository is the scaffold. Just git clone it and cd into the repo directory, then continue with Step 4.

Note that C is currently the only working path: thru dev init cpp and thru dev init rust both return "not yet implemented" in v0.2.38.

Checkpoint: you are inside a directory containing GNUmakefile and examples/hello_thru.c.

Step 4 โ€” Read the code

The entire program is examples/hello_thru.c:

/* hello-thru - Thru Program
 * A simple hello world program for the Thru blockchain
 */

#include <thru-sdk/c/tn_sdk.h>

TSDK_ENTRYPOINT_FN void
start( void const * instruction_data    TSDK_PARAM_UNUSED,
       ulong        instruction_data_sz TSDK_PARAM_UNUSED ) {
  tsdk_return( 0UL );
}

Line by line:

  • #include <thru-sdk/c/tn_sdk.h> โ€” the single SDK header; this is your entire interface to the ThruVM runtime.
  • TSDK_ENTRYPOINT_FN void start(...) โ€” the entrypoint macro marks start() as the function the VM calls when a transaction executes your program. There is no main().
  • instruction_data / instruction_data_sz โ€” a pointer to the raw bytes the caller attached to the transaction, and their length. This hello world ignores both (hence TSDK_PARAM_UNUSED), but this is where a real program reads its input and branches.
  • tsdk_return( 0UL ) โ€” hands a 64-bit result code back to the runtime. Returning 0 signals success, and it is exactly the Execution Result: 0 you will see in the transaction receipt in Step 8.

Checkpoint: you can state the whole contract in one sentence โ€” the VM calls start() with your instruction data, and you exit through tsdk_return().

Step 5 โ€” Build

make -j

Expected output: three artifacts, and the distinction matters:

  • build/thruvm/bin/hello_thru_c.bin โ€” 138 bytes. This is what you deploy. It is a flat ThruVM binary, not an ELF file: an 8-byte header, the bytecode, and an 8-byte zero trailer.
  • a .elf (42 KB) โ€” the debug build, useful with a debugger, never deployed.
  • a .s โ€” the generated assembly, if you want to see what your C actually compiles to.

Checkpoint: build/thruvm/bin/hello_thru_c.bin exists and is 138 bytes.

Step 6 โ€” Create an account and hit the faucet

Most chains have a bootstrapping problem: you need tokens to create an account, but an account to receive tokens. Thru doesn't:

thru account create

Expected output: account creation succeeds from a zero balance โ€” the CLI uses a fee payer proof (the makeStateProof RPC under the hood), so a brand-new key can create its own account with no pre-funding. From the verified session:

  • Account address (thrufmt ta..., 46 chars): taKmE6K78gqcXgqL5U7RkmNY2vip8OYzEEfRsbN7cifO5w
  • Creation signature (ts..., 90 chars): tszIE-13Z02YxVq-396e5EmGrydm7eonMgq2HCRxJ-WIaUUsUPZk0IqNNbnypmrEVdssjFrJ0qAUtw8RTBm1-EAyCh

Now fund it โ€” the faucet allows up to 10,000 per transaction:

thru faucet withdraw default 10000
thru getbalance default

Expected output:

Balance: 10_000

(Faucet signature from the session: tsQm7vaYR_Q8sd4GTjfMaZUWnh8iwlVEs90BlIrGTbJ9Z0jeYyC5nFs7oATYdPummka4fqJFZoTHGqrNmVkxY3AR8E)

Checkpoint: thru getbalance default prints Balance: 10_000.

Step 7 โ€” Deploy (one command, five transactions)

thru program create hello-thru-kuli build/thruvm/bin/hello_thru_c.bin

The first argument (hello-thru-kuli here) is a seed name of your choosing. One command โ€” but watch the output, because the CLI orchestrates an entire five-transaction deployment flow automatically:

  1. Create a temporary meta account + upload buffer.
  2. Write chunk 1/1 โ€” the 138 bytes fit in a single chunk (default chunk size is 30,720 bytes; bigger programs get split).
  3. Finalize the upload.
  4. Create the permanent managed program, again using a state proof.
  5. Delete the temporary buffer.

Expected output: from the verified session:

  • Meta account: ta88gvtxB4furilU7psKvefcBXKHyDteb1Bh2x0FgqQmyX
  • Program account: taoXfGFJWJi0CdC_IxEebrZoHJIGLSPjfZsdQBDdhqodsr

Confirm it:

thru program status hello-thru-kuli

Expected output: Program is DEPLOYED (138 bytes), owned by taAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQE.

Checkpoint: thru program status <your-seed> reports DEPLOYED with the exact byte size of your binary.

Step 8 โ€” Invoke it and read the receipt

thru txn execute taoXfGFJWJi0CdC_IxEebrZoHJIGLSPjfZsdQBDdhqodsr 00

Substitute your own program address from Step 7. The trailing 00 is one byte of instruction data โ€” this program ignores it, but the argument is required.

Expected output: from the verified session:

  • Signature: tsk4tEmApwurhGodqw-u55M_dZX_PlL6hmzLA3fnZjKyjIjfYTu_QxgUq1q-6frgps7xtVKwnL63pq-uZweF3QDyJX
  • Slot: 82908 ยท Compute Units: 4,763 ยท State Units: 0 ยท Pages: 1
  • VM Error: 0 (TN_RUNTIME_TXN_EXECUTE_SUCCESS) ยท Execution Result: 0

How to read this: VM Error: 0 is the runtime saying the transaction executed successfully โ€” don't let the word "Error" alarm you, 0 means success. Execution Result: 0 is your code: the 0UL you passed to tsdk_return() making the round trip back. The slot is where the transaction landed, Pages: 1 is the memory footprint, and 4,763 compute units is the metered cost of doing essentially nothing โ€” a useful baseline before you write real logic.

Checkpoint: the receipt shows VM Error: 0 (TN_RUNTIME_TXN_EXECUTE_SUCCESS).

Step 9 โ€” Verify it in the explorer

Two URL patterns, and one trap:

  • Transactions: https://scan.thru.org/tx/<signature>
  • Accounts and programs: https://scan.thru.org/address/<ta...> โ€” note it is /address/, not /account/ (that path returns 404).

The program deployed in this tutorial, live on alphanet: https://scan.thru.org/address/taoXfGFJWJi0CdC_IxEebrZoHJIGLSPjfZsdQBDdhqodsr

Checkpoint: your program account and execution transaction both load in the explorer.

What did all of this cost?

After account creation, the five deployment transactions, and one execution, the balance read 9_999 of the original 10_000. The entire journey โ€” create account, deploy, invoke โ€” cost roughly 1 testnet token, and the faucet allows up to 10,000 per transaction. Cost is not a constraint here; experiment freely.

Troubleshooting

Symptom Cause Fix
PowerShell: Error: Failed to detect OS: program not found on thru dev toolchain install The CLI shells out to uname, which plain Windows lacks Use WSL2 or a Linux VPS (Step 0)
Git Bash: Toolchain not found for MINGW64_NT-10.0-26200-x86_64 in release v0.2.38 v0.2.38 ships toolchains only for Linux-x86_64 and Darwin-arm64 Use WSL2 or a Linux VPS (Step 0)
SSH session drops during the ~2.5 GB toolchain download Long download, fragile connection Run the install under nohup or inside screen/tmux
Explorer shows 404 on scan.thru.org/account/<ta...> Wrong path โ€” accounts live under /address/ Use https://scan.thru.org/address/<ta...>
Worried about the key in ~/.thru/cli/config.yaml The CLI stores the private key in plaintext Treat it as testnet-only; never reuse for real funds
thru dev init cpp or thru dev init rust fails Both return "not yet implemented" in v0.2.38 Use thru dev init c โ€” C is the only working path

Next steps

  • Parse your instruction data. This program ignores that 00 byte; a real program reads its instruction data and branches on it. Designing that small ABI โ€” and building the counter program โ€” is covered in the official docs: https://thru.org/docs/program-development/building-a-c-program/
  • Wire up your AI tooling: the explorer exposes an MCP server at https://scan.thru.org/api/mcp so coding agents can query real chain state, and npx skills add https://thru.org/docs teaches your agent the Thru workflow.
  • Join the community: X @thru_xyz, Discord discord.gg/thru, Telegram t.me/thruxyz.
  • Watch the upstream mirror: https://github.com/Unto-Labs/thru.

Disclaimer & license

Thru has no token, no mainnet, and no announced incentive program โ€” nothing here promises or implies an airdrop; this is technical exploration on a testnet, done because the tech is interesting. The ThruVM audit reports (Neodyme, plus a second by OtterSec) remain unpublished as of this writing, known only from the team's own X announcement of 7 July 2026. And once more: the CLI stores your private key in plaintext at ~/.thru/cli/config.yaml โ€” keep it strictly to testnet.

This repository is licensed under Apache-2.0. The project scaffold was generated by the thru CLI (Unto-Labs/thru).


Verified against thru CLI 0.2.38+8eb269bd on a Linux VPS (Ubuntu 24.04, x86_64), alphanet node thru-node 0.3.0-dev, 8 July 2026.

About

A 138-byte C program, live on Thru alphanet - source, build setup, and bilingual tutorial (EN/ID)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages