Soroban Examples Coverage

This page maps upstream examples from stellar/soroban-examples to documented Solang Solidity examples or coverage in this repository.

The table below only includes upstream examples for which this repository currently has a clear Solidity counterpart or nearest documented coverage example. Absence from this table does not prove that an upstream example is impossible in Solang; it means there is not yet a documented counterpart in this repository.

For the current feature-oriented support status, see Soroban Support Matrix.

Documented Counterparts

Upstream Rust example

Solang Solidity example or coverage

Notes

alloc

tests/soroban_testcases/alloc.rs

Covered by Solidity testcases for dynamic memory arrays, including vector allocation, push(), iteration, and summation.

atomic_swap

docs/examples/soroban/atomic_swap

Atomic swap between two parties, with companion token contracts.

atomic_multiswap

docs/examples/soroban/atomic_swap and tests/soroban_testcases/alloc.rs

Closest documented Solang coverage is the atomic-swap example plus array and loop support used for batching-style logic. A dedicated standalone Solidity multiswap example is not yet present in this repository.

auth

docs/examples/soroban/auth.sol

Simple host-managed authorization via requireAuth().

cross_contract

integration/soroban/caller.sol and integration/soroban/callee.sol

Covered in cross_contract.spec.js.

deep_contract_auth

docs/examples/soroban/deep_auth

Nested contract authorization via authAsCurrContract(...).

hello_world

integration/soroban/callee.sol

Closest local Solidity counterpart for a minimal callable contract. Solang does not currently ship a string-vector hello-world example with the same interface.

increment

integration/soroban/counter.sol

Closest local counterpart for a stored counter that can be incremented.

liquidity_pool

docs/examples/soroban/liquidity_pool

Liquidity-pool and token-swap example with companion token contracts.

logging

docs/examples/soroban/error.sol

Demonstrates print()-based runtime logging in Solang.

timelock

docs/examples/soroban/timelock

Timelock-style example using enums, mappings, authorization, and block.timestamp.

token

docs/examples/soroban/token.sol

Token-style contract with balances, allowances, and Soroban auth.

events

tests/soroban_testcases/events.rs

Solidity event declarations and emit statements, with indexed fields mapping to Soroban topics and non-indexed fields mapping to event data.

ttl

docs/examples/soroban/ttl_storage.sol

Extending TTL on stored contract data.

Solidity Translations

The following abridged snippets show how selected upstream Soroban examples are expressed in Solang Solidity.

auth

Upstream Soroban example: auth

Solang Solidity example: docs/examples/soroban/auth.sol

contract auth {
    address public owner =
        address"GDRIX624OGPQEX264NY72UKOJQUASHU3PYKL6DDPGSTWXWJSBOTR6N7W";

    uint64 public instance counter = 20;

    function increment() public returns (uint64) {
        owner.requireAuth();
        counter = counter + 1;
        return counter;
    }
}

token

Upstream Soroban example: token

Solang Solidity example: docs/examples/soroban/token.sol

contract token {
    address public admin;
    mapping(address => int128) public balances;

    constructor(address _admin, string memory _name, string memory _symbol, uint32 _decimals) {
        admin = _admin;
    }

    function mint(address to, int128 amount) public {
        require(amount >= 0, "Amount must be non-negative");
        admin.requireAuth();
        balances[to] = balances[to] + amount;
    }

    function transfer(address from, address to, int128 amount) public {
        from.requireAuth();
        balances[from] = balances[from] - amount;
        balances[to] = balances[to] + amount;
    }
}

timelock

Upstream Soroban example: timelock

Solang Solidity example: docs/examples/soroban/timelock/timelock.sol

contract timelock {
    enum TimeBoundKind { Before, After }

    struct TimeLock {
        TimeBoundKind kind;
        uint64 bound_timestamp;
        address claimant;
        uint64 amount;
    }

    mapping(address => TimeLock) public timelocks;

    function is_claimable(address claimant) public view returns (bool) {
        TimeLock storage tl = timelocks[claimant];
        return block.timestamp >= tl.bound_timestamp;
    }
}

ttl

Upstream Soroban example: ttl

Solang Solidity example: docs/examples/soroban/ttl_storage.sol

contract ttl_storage {
    uint64 public persistent pCount = 11;
    uint64 temporary tCount = 7;
    uint64 instance iCount = 3;

    function extend_persistent_ttl() public view returns (int64) {
        return pCount.extendTtl(1000, 5000);
    }

    function extend_temp_ttl() public view returns (int64) {
        return tCount.extendTtl(3000, 7000);
    }
}

Upstream Examples Not Yet Documented as Supported

The following upstream examples do not currently have a documented Solidity counterpart, as some needed Soroban features are not yet supported. - bls_signature - custom_types - deployer - errors - eth_abi - fuzzing - merkle_distribution - mint-lock - other_custom_types - privacy-pools - simple_account - single_offer - upgradeable_contract - workspace

Want to add support for one of the remaining examples? Open a pull request against hyperledger-solang/solang and follow the contribution guide.