| Crates.io | vialabs-stellar-common |
| lib.rs | vialabs-stellar-common |
| version | 0.1.10 |
| created_at | 2025-10-31 16:57:11.949591+00 |
| updated_at | 2025-11-10 19:05:15.299321+00 |
| description | Common interfaces, types, and utilities for Stellar contracts in the VIA cross-chain messaging system |
| homepage | |
| repository | https://github.com/vialabs-io/via-drivers |
| max_upload_size | |
| id | 1910336 |
| size | 129,342 |
Common interfaces, types, and utilities for Stellar contracts in the VIA cross-chain messaging system.
The vialabs-stellar-common crate provides shared interfaces, types, error definitions, encoding utilities, and helper functions used across Stellar contracts in the VIA ecosystem. This crate promotes code reuse, type safety, and consistency across contracts.
message_client_v4 - Interface and base implementation for message client contractsmessage_gateway_v4 - Interface for message gateway contractsencoding - Encoding and decoding utilities for cross-chain data (EVM, VIA formats)utils - Helper functions for address validation and common operationsstorage - Storage keys and data structures used across contractserrors - Standard error types for contract operationsfee - Fee handler contract interfacegas - Gas handler contract interfacepos - Proof of Stake (POS) handler contract interfaceAdd the common crate to your contract's Cargo.toml:
[dependencies]
vialabs-stellar-common = "0.1.7"
soroban-sdk = "23.0.2"
use vialabs_stellar_common::message_client_v4::{
MessageClientV4Interface,
ProcessFromGatewayRequest,
Base
};
use vialabs_stellar_common::message_gateway_v4::{
MessageGatewayV4Interface,
SendRequest,
ProcessRequest
};
use vialabs_stellar_common::encoding::evm::{
encode_abi_chain_data,
decode_abi_chain_data
};
let encoded = encode_abi_chain_data(&env, &recipient, amount, &text);
let (recipient, amount, text) = decode_abi_chain_data(&env, &encoded);
use vialabs_stellar_common::utils::{is_zero_address, validate_address_bytes};
let is_zero = is_zero_address(&env, address_bytes);
let is_valid = validate_address_bytes(&env, signer, public_key);
use vialabs_stellar_common::errors::Error;
panic_with_error!(env, Error::MissingMessageGateway);
The MessageClientV4Interface trait defines the interface for cross-chain message client contracts. The Base implementation provides default functionality that can be used via the #[default_impl] macro from vialabs-stellar-macros.
Contracts implementing MessageClientV4Interface must implement the message_process method, which handles incoming cross-chain messages.
All other methods have default implementations that can be automatically included using the #[default_impl] macro.
The MessageGatewayV4Interface trait defines the interface for the message gateway contract, which handles routing and processing of cross-chain messages.
The encoding module provides utilities for encoding and decoding data in formats compatible with Ethereum (EVM) and other chains.
The storage module defines common storage keys used across contracts to ensure consistency and avoid conflicts.