Web3 programming languages: Solidity, Rust, Move and how to choose

GoldRush TeamUpdated 12 min read

The languages web3 runs on, by chain: Solidity and Vyper for EVM, Rust for Solana, Move for Aptos and Sui, Cairo and more, with code and how to choose one.

Web3 programming languages fall into two groups. Smart contract languages compile to code that runs on a blockchain's virtual machine: Solidity and Vyper on Ethereum and every EVM chain, Rust on Solana, Move on Aptos and Sui, Cairo on Starknet. Client languages are ordinary languages, mostly TypeScript, Python, Go and Rust, that you use to build the apps, bots, backends and nodes that talk to those contracts.

Which contract language you need is decided almost entirely by the chain you build on. This guide maps each language to the chains that run it, shows the same small contract in Solidity, Vyper, Rust (Anchor) and Move, and ends with a way to choose.

Web3 programming languages compared

Language Runs on What it is Main tooling
Solidity Ethereum and every EVM chain (Base, Arbitrum, Polygon, …) Statically typed, contract-oriented, curly-brace syntax Foundry, Hardhat, Remix, OpenZeppelin Contracts
Vyper Ethereum and EVM chains Pythonic syntax, deliberately fewer features, easier to audit Vyper compiler, Titanoboa, Ape
Yul and Huff Ethereum and EVM chains Low-level EVM languages for gas-critical code solc (Yul), the Huff compiler
Rust Solana, NEAR, Cosmos (CosmWasm), Polkadot (ink!), Arbitrum Stylus Systems language; each chain has its own SDK or framework Anchor and the Solana CLI, near-sdk, CosmWasm, ink!
Move Aptos and Sui (each with its own dialect) Resource-oriented: assets are values that can't be copied or dropped Aptos CLI, Sui CLI
Cairo Starknet Rust-like language for provable (STARK) programs Scarb, Starknet Foundry
Haskell (Plutus) and Aiken Cardano Functional languages that compile to Plutus Core Plutus tools, Aiken
Cadence Flow Resource-oriented contract language Flow CLI
Motoko Internet Computer Actor-based language for canisters (Rust also works there) dfx
TypeScript / JavaScript Off-chain, every chain Frontends, scripts, tests and backends viem, ethers, @solana/kit
Python Off-chain, every chain Scripts, data work, backends web3.py
Go Off-chain: nodes and backends Ethereum's Geth client and the Cosmos SDK are written in Go go-ethereum

The first rule of the table: a contract written in one VM's language does not run on another VM. Solidity code doesn't run on Solana, and Anchor programs don't run on Ethereum. Within one VM family, though, code is portable: the same Solidity contract deploys to Ethereum and to any EVM chain unchanged.

Smart contract languages vs client languages

A web3 app usually needs both kinds of language.

  • On-chain: the contract or program, written in the chain's contract language. It holds the rules and the state (balances, ownership, positions), costs gas or fees to run, and is very hard to change once deployed.
  • Off-chain: everything that calls it. The frontend that asks a wallet to sign, the script that deploys, the bot that watches events, the backend that indexes history, the node that runs the chain. These are written in general-purpose languages, and a single TypeScript or Python codebase can talk to many chains.

Many web3 developers never write a contract. If you are building wallets, analytics, dashboards, trading tools or AI agents that read blockchain data, the client language and a good data source matter more than Solidity.

Solidity

Solidity is the main language for Ethereum smart contracts and, because it compiles to EVM bytecode, for every EVM-compatible chain. It is statically typed, has contracts, inheritance, libraries, events and custom errors, and its syntax looks familiar to anyone who knows JavaScript, C++ or Java. See the Solidity documentation.

A minimal counter that stores a number and emits an event each time it changes (compiled with solc 0.8.28):

// SPDX-License-Identifier: MITpragma solidity ^0.8.24; contract Counter {    uint256 public count;     event Incremented(address indexed by, uint256 newCount);     function increment() external {        count += 1; // reverts on overflow since Solidity 0.8        emit Incremented(msg.sender, count);    }}

count lives in the contract's own storage, public generates a getter, and the Incremented event is what apps and indexers read to follow the contract's activity. The compiler emits the bytecode and an ABI, the JSON interface clients use to call it.

The ecosystem is the reason most people start here: Foundry and Hardhat for testing and deployment, Remix in the browser, OpenZeppelin Contracts for audited token and access-control building blocks, and a large pool of example code and auditors.

Vyper

Vyper is the other high-level EVM language. It uses Python-like syntax and leaves out features on purpose (no inheritance, no modifiers, no inline assembly) so contracts are easier to read and audit. Curve's pools are written in Vyper. See the Vyper documentation.

The same counter in Vyper (compiled with Vyper 0.4.0):

# pragma version ^0.4.0 count: public(uint256) event Incremented:    by: indexed(address)    newCount: uint256 @externaldef increment():    self.count += 1  # overflow reverts    log Incremented(msg.sender, self.count)

Both contracts compile to EVM bytecode with the same ABI: one count() view, one increment() function and one Incremented event. A wallet, a frontend or an indexer can't tell which language a contract was written in.

Yul and Huff: low-level EVM

Yul is an intermediate language for the EVM. Solidity compiles through it, and you can write it directly in Solidity's assembly { ... } blocks to hand-optimize gas-critical code. Huff goes further: a macro assembler where you write EVM opcodes almost one by one. Both give up the compiler's safety checks for control over every byte, so they are for small, heavily tested pieces of a contract, not a place to start.

Rust

Rust is a contract language on several non-EVM chains, and each one uses it differently:

  • Solana: programs are written in Rust and compiled to sBPF bytecode, usually with the Anchor framework.
  • NEAR: contracts use near-sdk and compile to WebAssembly.
  • Cosmos: chains that enable CosmWasm run Rust contracts compiled to WebAssembly.
  • Polkadot: ink! is a Rust-based language for WebAssembly contracts on Substrate chains.
  • Arbitrum Stylus: Rust contracts compiled to WebAssembly run alongside EVM contracts and can call them.

Rust is also everywhere off-chain: Foundry is written in Rust, Reth is a Rust Ethereum client, and Agave, Solana's main validator client, is written in Rust.

The counter as a Solana program with Anchor (it passes cargo check against anchor-lang 0.31.1). The program holds no state: the count lives in a separate account the program owns, and every instruction declares the accounts it touches:

use anchor_lang::prelude::*; declare_id!("GmrkvPmNEhqHMYUreUdjb1BvakNtimt2uiUeJXnt857x"); // replaced by `anchor keys sync` #[program]pub mod counter {    use super::*;     pub fn initialize(ctx: Context<Initialize>) -> Result<()> {        ctx.accounts.counter.count = 0;        Ok(())    }     pub fn increment(ctx: Context<Increment>) -> Result<()> {        let counter = &mut ctx.accounts.counter;        counter.count = counter.count.checked_add(1).unwrap();        emit!(Incremented { by: ctx.accounts.user.key(), new_count: counter.count });        Ok(())    }} // State lives in an account the program owns, not inside the program.#[account]#[derive(InitSpace)]pub struct Counter {    pub count: u64,} #[event]pub struct Incremented {    pub by: Pubkey,    pub new_count: u64,} // Every account an instruction touches is declared up front.#[derive(Accounts)]pub struct Initialize<'info> {    #[account(init, payer = user, space = 8 + Counter::INIT_SPACE)]    pub counter: Account<'info, Counter>,    #[account(mut)]    pub user: Signer<'info>,    pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct Increment<'info> {    #[account(mut)]    pub counter: Account<'info, Counter>,    pub user: Signer<'info>,}

The extra code is the account model at work, not Rust verbosity: space reserves the account's size, payer funds its storage deposit, and declaring accounts up front is what lets Solana run non-conflicting transactions in parallel. Ethereum vs Solana for developers explains that model in full.

Move

Move was created at Meta for the Diem blockchain and is now the contract language of Aptos and Sui. Its core idea is resources: a struct that represents an asset can't be copied or silently dropped unless its type allows it, so the compiler catches whole classes of bugs, such as tokens created or destroyed by accident. Aptos and Sui use different dialects (Sui Move is built around objects with IDs), so code doesn't move between them unchanged. See The Move Book for Sui and aptos.dev for Aptos.

The counter as a Sui Move shared object. This module has not been compiled for this guide yet: run sui move build on it before you rely on it.

module counter::counter {    public struct Counter has key {        id: UID,        value: u64,    }     /// Creates a counter that anyone can increment.    public fun create(ctx: &mut TxContext) {        transfer::share_object(Counter { id: object::new(ctx), value: 0 })    }     public fun increment(counter: &mut Counter) {        counter.value = counter.value + 1;    }     public fun value(counter: &Counter): u64 {        counter.value    }}

has key makes Counter an object that lives in global storage with its own ID; it has no copy or drop ability, so a counter can't be duplicated or thrown away by mistake.

Cairo and other chain-specific languages

  • Cairo (Starknet): programs whose execution can be proven with STARK proofs, which is how Starknet scales Ethereum. Modern Cairo has Rust-like syntax. See cairo-lang.org.
  • Haskell (Plutus) and Aiken (Cardano): Cardano validators compile to Plutus Core. Plutus Tx lets you write them in Haskell; Aiken is a newer language built for the job.
  • Cadence (Flow): a resource-oriented language in the same spirit as Move.
  • Motoko (Internet Computer): an actor-based language for canisters, the Internet Computer's contracts. Rust is the other common choice there.
  • Tact, FunC and Tolk (TON): TON's contract languages.
  • Bitcoin Script: Bitcoin's deliberately limited, non-Turing-complete scripting language for spending conditions. Bitcoin Core itself is written in C++.

Learn one of these when you are committed to its chain: each one is used on its chain and almost nowhere else.

Client languages: TypeScript, Python, Go

These don't run on-chain, but they are where most web3 code is written.

  • TypeScript / JavaScript: frontends, wallets, deployment scripts and tests. viem and ethers for EVM chains, @solana/kit for Solana, and Hardhat tests are usually written in TypeScript.
  • Python: web3.py for EVM chains, plus data analysis, bots and backends. Vyper's tooling (Titanoboa, Ape) is Python too.
  • Go: nodes and infrastructure. Geth, an Ethereum execution client, is written in Go, as is the Cosmos SDK that Cosmos chains are built with.
  • Rust: clients and infrastructure too, as above.

Because both counters above share one ABI, the client code is the same whichever language the contract was written in. This script reads one value from USDC (written in Solidity) and one from Curve's 3pool (written in Vyper) with identical viem calls.

Prerequisites: Node.js 18 or later, a GoldRush API key in the GOLDRUSH_API_KEY environment variable, and viem:

npm install viem@2.52.2

Save the script as read-contracts.mts (TypeScript with top-level await, so it must run as an ES module) and run it with npx tsx@4.23.15 read-contracts.mts. GoldRush JSON-RPC takes the key in an Authorization: Bearer header, never in the URL, so the transport sets it through viem's fetchOptions:

import { createPublicClient, formatUnits, http, parseAbi } from "viem";import { mainnet } from "viem/chains"; const client = createPublicClient({    chain: mainnet,    transport: http("https://rpc.goldrushdata.com/v1/eth-mainnet", {        fetchOptions: { headers: { Authorization: `Bearer ${process.env.GOLDRUSH_API_KEY}` } },    }),}); // USDC is written in Solidity; Curve's 3pool is written in Vyper. The client code is the same.const usdcSupply = await client.readContract({    address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",    abi: parseAbi(["function totalSupply() view returns (uint256)"]),    functionName: "totalSupply",}); const virtualPrice = await client.readContract({    address: "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",    abi: parseAbi(["function get_virtual_price() view returns (uint256)"]),    functionName: "get_virtual_price",}); console.log("USDC supply:", formatUnits(usdcSupply, 6));console.log("3pool virtual price:", formatUnits(virtualPrice, 18));

The URL is GoldRush JSON-RPC on Ethereum mainnet. To use another Ethereum RPC endpoint, replace the URL and drop fetchOptions if it needs no header. A contract call answers "what is the state now". For history (every event a contract has emitted, decoded), an indexed API saves you scanning blocks yourself: the GoldRush Foundational API returns a contract's decoded logs with the Contract Event Logs API (credit cost: 0.01 per item), whatever language the contract was written in.

Handle errors from GoldRush JSON-RPC

GoldRush JSON-RPC answers an authentication or billing failure with the standard JSON-RPC error envelope and a matching HTTP status. The docs show this body for a request whose Authorization header is missing or malformed (HTTP 401):

{    "jsonrpc": "2.0",    "id": 1,    "error": {        "code": -32001,        "message": "missing or invalid Authorization header"    }}

-32001 means the key never reached the server: send it in the Authorization: Bearer header, as the transport above does, never in the URL. The related codes are -32002 (HTTP 403, the key has no JSON-RPC entitlement), -32003 (HTTP 402, out of credits) and -32005 (HTTP 429, rate limited: wait for Retry-After, then retry). viem throws on these responses, so the script stops with the status and message instead of printing a value. The JSON-RPC authentication docs list each code and its fix.

How to choose a web3 programming language

Start from the chain and the job, not the language.

  1. Pick the chain first. If you are building on Ethereum, an Ethereum rollup or any EVM chain, learn Solidity. On Solana, learn Rust and Anchor. On Aptos or Sui, Move. On Starknet, Cairo. Each chain's documentation names its language.
  2. Not sure which chain yet? Start with Solidity. It reaches the most chains with one skill set and has the deepest pool of examples, audited libraries and tooling. Moving to Vyper, Yul or another EVM chain later costs little.
  3. Building apps, not contracts? Learn TypeScript. The main client libraries (viem and ethers for EVM chains, @solana/kit for Solana) are TypeScript, browser frontends run JavaScript, and it works with every chain. Python is the alternative for data and analytics work.
  4. Already know Rust? Solana, NEAR, CosmWasm and Arbitrum Stylus all use it, and Rust carries over to infrastructure work.
  5. Security is the real learning curve. In every contract language the hard part is the execution model (reentrancy, access control, account validation, integer handling), not the syntax. Budget time for testing tools and audits.

Frequently asked questions

What is the best programming language for web3?

There isn't one: the chain decides. Solidity covers Ethereum and every EVM chain, Rust covers Solana and several WebAssembly chains, and Move covers Aptos and Sui. For the apps around contracts, TypeScript is the most common choice because it works with every chain.

Should I learn Solidity or Rust first?

Solidity, unless you already know which chain you're building on. Solidity reaches Ethereum and every EVM chain with one skill set and has the deepest tooling and examples. Learn Rust first if you are building on Solana or another Rust chain, or already write Rust.

Can I write smart contracts in Python or JavaScript?

On EVM chains, not directly: Vyper has Python-like syntax but is its own language, and contracts must compile to EVM bytecode. Python (web3.py) and JavaScript or TypeScript (viem, ethers) are the main languages for the code that deploys, calls and tests contracts.

What programming language does Solana use?

Solana programs are written mostly in Rust, usually with the Anchor framework, and compiled to sBPF bytecode. Clients are usually TypeScript with @solana/kit. Solidity contracts don't run on Solana.

What are Yul and Huff used for?

Writing EVM code by hand where gas matters most. Yul is the intermediate language Solidity compiles through and can be written inline in Solidity's assembly blocks; Huff is a lower-level macro assembler. Both skip the compiler's safety checks, so they are used for small, heavily tested parts of a contract.

Is Move better than Solidity?

They make different trade-offs. Move's resource types stop assets from being copied or lost by accident at compile time, which removes some bug classes Solidity developers guard against by hand. Solidity has a far larger ecosystem and runs on many more chains. Move only runs on Move chains such as Aptos and Sui.

Next steps

Get new guides by email

New tutorials and best practices for building with blockchain data, sent as they're published.