Skip to main content

shard_of

Function shard_of 

Source
pub fn shard_of(address: &str, num_shards: u32) -> Result<u32, CoreError>
Expand description

Determines the shard ID for a given bech32 address.

This implementation matches the Go reference: mx-chain-go/sharding/multiShardCoordinator.go

§Arguments

  • address - A bech32-encoded MultiversX address
  • num_shards - The total number of shards in the network

§Returns

The shard ID (0 to num_shards-1) or METACHAIN_SHARD_ID for metachain

§Errors

Returns an error if the address is not a valid bech32 string