Skip to content

Python SDK Reference

MethodCategoryReturnsPage
Keypair.generate()KeypairKeypairKeypair
Keypair.from_secret_key()KeypairKeypairKeypair
Keypair.from_mnemonic()KeypairKeypairKeypair
get_chain_identifier()ChainstrChain & State
get_server_version()ChainstrChain & State
get_protocol_version()ChainintChain & State
get_architecture_version()ChainintChain & State
get_embedding_dim()ChainintChain & State
get_model_min_stake()ChainintChain & State
check_api_version()ChainNoneChain & State
get_object()ObjectsObjectRefChain & State
get_balance()ObjectsintChain & State
list_owned_objects()Objectslist[ObjectRef]Chain & State
get_latest_system_state()SystemSystemStateChain & State
get_epoch()SystemEpochInfoChain & State
get_latest_checkpoint()CheckpointsCheckpointSummaryChain & State
wait_for_next_epoch()EpochintChain & State
list_targets()TargetsListTargetsResponseTargets & Challenges
get_targets()Targetslist[Target]Targets & Challenges
get_model_manifests()Targetslist[ModelManifest]Targets & Challenges
get_challenge()ChallengesChallengeInfoTargets & Challenges
list_challenges()ChallengesListChallengesResponseTargets & Challenges
execute_transaction()TransactionsTransactionEffectsTransactions
simulate_transaction()TransactionsTransactionEffectsTransactions
get_transaction()TransactionsTransactionEffectsTransactions
build_transfer_coin()BuildersbytesTransactions
build_add_stake()BuildersbytesTransactions
build_commit_model()BuildersbytesTransactions
build_submit_data()BuildersbytesTransactions
score()ScoringScoreResultScoring & Admin
request_faucet()FaucetFaucetResponseScoring & Admin
commit_model()ConveniencestrScoring & Admin
reveal_model()ConvenienceNoneScoring & Admin
submit_data()ConvenienceNoneScoring & Admin
claim_rewards()ConvenienceNoneScoring & Admin
pip install soma-sdk
from soma_sdk import SomaClient
client = await SomaClient(
rpc_url="http://127.0.0.1:9000",
scoring_url="http://127.0.0.1:9124",
faucet_url="http://127.0.0.1:9123",
)
ParameterTypeRequiredDefaultDescription
rpc_urlstrYesgRPC endpoint for the SOMA fullnode
scoring_urlstrNoNoneScoring service URL (required for score())
admin_urlstrNoNoneAdmin endpoint (required for advance_epoch())
faucet_urlstrNoNoneFaucet endpoint (required for request_faucet())

The constructor is async — use await to initialize the client.

All query and transaction methods are async. Use asyncio.run() for scripts:

import asyncio
from soma_sdk import SomaClient
async def main():
client = await SomaClient("http://127.0.0.1:9000")
balance = await client.get_balance("0x1234...")
print(f"Balance: {balance} shannons")
asyncio.run(main())

These methods are available on SomaClient without instantiation.

Encrypt data with AES-256-CTR (zero IV). If no key is provided, one is generated.

encrypted, key_hex = SomaClient.encrypt_weights(data)
encrypted_with_key, _ = SomaClient.encrypt_weights(data, key=my_key)
ParameterTypeRequiredDefaultDescription
databytesYesRaw data to encrypt
keybytesNoNone32-byte AES key (generated if omitted)

Returns: tuple[bytes, str](encrypted_bytes, key_hex)

Decrypt data encrypted with encrypt_weights.

decrypted = SomaClient.decrypt_weights(encrypted, key_hex)
ParameterTypeRequiredDefaultDescription
databytesYesEncrypted data
keybytes | strYesAES key (bytes or hex string)

Returns: bytes

Compute a Blake2b-256 hash of data.

digest = SomaClient.commitment(data) # 64-char hex string
ParameterTypeRequiredDefaultDescription
databytesYesData to hash

Returns: str — 64-character hex string

Convert SOMA to shannons (1 SOMA = 1,000,000,000 shannons).

shannons = SomaClient.to_shannons(1.5) # 1_500_000_000

Convert shannons to SOMA.

soma = SomaClient.to_soma(1_500_000_000) # 1.5