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 |
|---|---|---|
Covered by Solidity testcases for dynamic memory arrays, including vector allocation, |
||
Atomic swap between two parties, with companion token contracts. |
||
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. |
|
Simple host-managed authorization via |
||
integration/soroban/caller.sol and integration/soroban/callee.sol |
Covered in cross_contract.spec.js. |
|
Nested contract authorization via |
||
Closest local Solidity counterpart for a minimal callable contract. Solang does not currently ship a string-vector hello-world example with the same interface. |
||
Closest local counterpart for a stored counter that can be incremented. |
||
Liquidity-pool and token-swap example with companion token contracts. |
||
Demonstrates |
||
Timelock-style example using enums, mappings, authorization, and |
||
Token-style contract with balances, allowances, and Soroban auth. |
||
Solidity |
||
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.