Getting Started with MoltChain

This guide walks you through everything needed to go from zero to your first on-chain transaction. You'll install the toolchain, create a wallet, fund it on testnet, send a transfer, and deploy a minimal smart contract.

Prerequisites

1
Rust Toolchain
MoltChain contracts compile to WASM via Rust. Install the latest stable Rust toolchain.
Shell
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default stable
rustup update
2
WASM Target
Add the wasm32-unknown-unknown compilation target for smart contract builds.
Shell
rustup target add wasm32-unknown-unknown
3
Node.js (Optional)
Required only if you plan to use the JavaScript SDK. Node.js 18+ recommended.
Shell
# Using nvm (recommended)
nvm install 20
nvm use 20

# Verify
node --version  # v20.x.x
npm --version   # 10.x.x
Tip
You can skip Node.js if you only plan to write Rust contracts and use the CLI. The JavaScript SDK is optional.

Install the CLI

The molt CLI is your primary interface for interacting with the MoltChain network. Install it from crates.io or build from source.

Option A: Install from crates.io

Shell
cargo install moltchain-cli

Option B: Build from source

Shell
git clone https://github.com/moltchain/moltchain.git
cd moltchain
cargo build --release
# Binary is at ./target/release/molt
cp target/release/molt ~/.cargo/bin/

Verify the installation:

Shell
$ molt --version
molt-cli 0.9.2 (moltchain)

Make molt discoverable in new shells

Shell
echo 'export PATH="$HOME/.cargo/bin:$HOME/.moltchain/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
command -v molt

If command -v molt is empty, run the binary directly until your shell profile is fixed:

Shell
./target/release/molt --version

Create a Wallet

Generate a new keypair. This creates an Ed25519 private key and derives your MoltChain address.

Shell
$ molt wallet create

 Generating new MoltChain keypair...

  Address:  Mo1tABcDeFgH1jK2LmNoPqRsTuVwXyZ3456789ab
  Mnemonic: lobster dawn harbor quiet oven maple drift ocean signal bright collect badge

  Keypair saved to: ~/.moltchain/wallet.json

 Done! Fund your wallet with testnet tokens to get started.
Warning — Secure Your Mnemonic
Your mnemonic phrase is the only way to recover your wallet. Write it down on paper and store it securely offline. Never share it, commit it to version control, or paste it into websites. Anyone with your mnemonic has full control of your funds.

You can also import an existing mnemonic:

Shell
$ molt wallet import --mnemonic "lobster dawn harbor quiet oven maple drift ocean signal bright collect badge"

Get Testnet Tokens

You need MOLT tokens to pay for transaction fees and contract deployments. On testnet, you can request free tokens from the faucet.

Option A: Web Faucet

Visit the MoltChain Faucet and paste your address. You'll receive 10 MOLT on testnet within seconds.

Option B: CLI Faucet

Shell
$ molt airdrop 10 --url https://testnet-rpc.moltchain.io

 Requesting 10 MOLT airdrop...

  Transaction: 4xK9...mNpQ
  New balance: 10.000000000 MOLT

 Airdrop successful!
Note
Testnet tokens have no monetary value. The faucet rate-limits to 10 MOLT per address per hour. If you need more for contract testing, use a local validator with molt-test-validator.

First Transfer

Send MOLT from your wallet to another address. This is the simplest transaction on MoltChain.

Shell
$ molt transfer 1.5 Mo1tRecipientAddress123456789abcdefghijk \
    --url https://testnet-rpc.moltchain.io

 Sending 1.5 MOLT...

  From:        Mo1tABcDeFgH1jK2LmNoPqRsTuVwXyZ3456789ab
  To:          Mo1tRecipientAddress123456789abcdefghijk
  Amount:      1.500000000 MOLT
  Fee:         0.000005000 MOLT
  Transaction: 7zQ3...bRtW
  Status:      Finalized (slot 482,917)

 Transfer complete!

Verify the transaction in the Block Explorer by searching for the transaction hash.

Deploy a Contract

Let's deploy a minimal "Hello World" smart contract. MoltChain contracts are written in Rust and compiled to WASM.

1
Create the project
Scaffold a new contract project using the CLI.
Shell
$ molt init hello-world --template contract
$ cd hello-world
2
Write the contract
Open src/lib.rs and add the contract logic.
Rust
use moltchain_sdk::prelude::*;

#[moltchain_contract]
mod hello_world {
    use super::*;

    /// Store a greeting message on-chain.
    pub fn set_greeting(ctx: Context, message: String) -> Result<()> {
        let greeting_account = &mut ctx.accounts.greeting;
        greeting_account.message = message.clone();
        greeting_account.author = ctx.caller();
        emit_event("GreetingSet", &message);
        Ok(())
    }

    /// Read the current greeting.
    pub fn get_greeting(ctx: Context) -> Result<String> {
        Ok(ctx.accounts.greeting.message.clone())
    }
}

#[account]
pub struct GreetingAccount {
    pub message: String,
    pub author: Pubkey,
}
3
Build to WASM
Compile the contract to a WASM binary.
Shell
$ cargo build --target wasm32-unknown-unknown --release

   Compiling hello-world v0.1.0
    Finished release [optimized] target(s) in 8.42s
4
Deploy to testnet
Upload the WASM binary and create the program account on-chain.
Shell
$ molt deploy target/wasm32-unknown-unknown/release/hello_world.wasm \
    --url https://testnet-rpc.moltchain.io

 Deploying contract...

  Program ID:  Mo1tProg1D...xYz789
  Size:        14,832 bytes
  Deploy tx:   9kR7...sWmN
  Fee:         0.014832000 MOLT
  Status:      Finalized

 Contract deployed successfully!

  Interact via:
    molt call Mo1tProg1D...xYz789 set_greeting '["Hello, MoltChain!"]'
Tip
Deployment cost scales with WASM binary size and runtime pricing parameters (it is not a flat 25 MOLT fee). Optimize your binary with wasm-opt to reduce cost: wasm-opt -Oz -o optimized.wasm hello_world.wasm

Next Steps

You've created a wallet, funded it, sent a transfer, and deployed a contract. Here's where to go next: