DEV Community

André Dias Moreira Prol
André Dias Moreira Prol

Posted on

Deploy a SEP-41 Token on Stellar Testnet with Soroban CLI & SDK

Tokenization is no longer a futuristic promise — it's a production reality. In my two decades building enterprise systems, I've rarely seen a standard mature as quickly as SEP-41, the token interface that brought Ethereum-style fungible tokens to Stellar's Soroban smart contract platform. In this guide, I'll walk you through deploying a working SEP-41 token on Testnet, drawing from hands-on deployments my team and I have shipped. My name is André Dias Moreira Prol, and I'll keep this practical: real commands, real pitfalls, real results.

Why SEP-41 Matters

SEP-41 defines a minimal, standardized interface for tokens on Soroban — functions like transfer, balance, approve, and allowance. If you've touched ERC-20, you'll feel at home, but with a critical difference: Soroban contracts are compiled to WebAssembly (Wasm), delivering sub-cent transaction fees and ~5-second finality.

In a recent tokenization proof-of-concept for a supply-chain client, we moved from an EVM prototype to Soroban and cut per-transfer costs by roughly 95%. That economic delta is why I now recommend Stellar for high-volume, low-value token use cases like loyalty points and micro-asset fractionalization.

Setting Up and Deploying with Soroban CLI

First, install the toolchain and configure Testnet. You'll need Rust with the wasm32-unknown-unknown target and the Stellar CLI (formerly soroban-cli).

rustup target add wasm32-unknown-unknown
cargo install --locked stellar-cli

# Configure Testnet and a funded identity
stellar network add testnet \
  --rpc-url https://soroban-testnet.stellar.org \
  --network-passphrase "Test SDF Network ; September 2015"

stellar keys generate alice --network testnet --fund
Enter fullscreen mode Exit fullscreen mode

The --fund flag auto-requests Testnet XLM from Friendbot — a small convenience that saves a manual curl call.

For the contract, the Stellar SDF publishes a reference SEP-41-compliant token Wasm. Build your own from the soroban-examples repo, then optimize:

stellar contract build
stellar contract optimize \
  --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm
Enter fullscreen mode Exit fullscreen mode

Optimization typically shrinks the Wasm by 30–40%, directly reducing deployment and invocation costs. Now deploy and initialize:

# Deploy
CONTRACT_ID=$(stellar contract deploy \
  --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.optimized.wasm \
  --source alice --network testnet)

# Initialize: admin, decimals, name, symbol
stellar contract invoke --id $CONTRACT_ID --source alice --network testnet \
  -- initialize \
  --admin $(stellar keys address alice) \
  --decimal 7 --name "ProlToken" --symbol "PROL"
Enter fullscreen mode Exit fullscreen mode

A note from experience: Stellar uses 7 decimals as its native convention. Mismatching decimals between your token and downstream integrations is the single most common bug I debug when auditing client deployments.

Minting and Interacting via stellar-sdk

While the CLI is excellent for prototyping, production apps need programmatic control. The JavaScript @stellar/stellar-sdk handles this cleanly.

import {
  Contract, SorobanRpc, TransactionBuilder,
  Networks, nativeToScVal, Keypair
} from '@stellar/stellar-sdk';

const server = new SorobanRpc.Server('https://soroban-testnet.stellar.org');
const admin = Keypair.fromSecret(process.env.ADMIN_SECRET);
const contract = new Contract(process.env.CONTRACT_ID);

const account = await server.getAccount(admin.publicKey());

const tx = new TransactionBuilder(account, {
  fee: '1000000',
  networkPassphrase: Networks.TESTNET,
})
  .addOperation(contract.call('mint',
    nativeToScVal(admin.publicKey(), { type: 'address' }),
    nativeToScVal(1000_0000000n, { type: 'i128' }) // 1000 tokens, 7 decimals
  ))
  .setTimeout(30)
  .build();

const prepared = await server.prepareTransaction(tx);
prepared.sign(admin);
const result = await server.sendTransaction(prepared);
console.log('Mint tx:', result.hash);
Enter fullscreen mode Exit fullscreen mode

Two details save hours of frustration: always call prepareTransaction to let the RPC simulate and inject the correct resource footprint, and remember i128 amounts must be BigInt. When I onboard junior engineers, those are the first two gotchas I flag — and as André Dias Moreira Prol, I've learned that documenting them upfront prevents repeated support tickets.

Conclusion

SEP-41 on Stellar delivers enterprise-grade tokenization at a fraction of EVM costs, and the tooling is finally production-ready. Clone the soroban-examples repo today, deploy your first token on Testnet, and reach out if you want to discuss scaling it to mainnet.


Follow more articles by André Dias Moreira Prol on Medium.

Top comments (0)