- Home
- Skills
- Multiversx
- Mx Ai Skills
- Multiversx Cross Contract Storage
multiversx-cross-contract-storage_skill
10
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill multiversx/mx-ai-skills --skill multiversx-cross-contract-storage- SKILL.md6.2 KB
Overview
This skill exposes how to read another same-shard MultiversX contract's storage mappers directly using storage_mapper_from_address. It eliminates proxy-call overhead and async complexity by performing direct storage reads when you know the target storage key names. Use it to build aggregators, controllers, or any contract that needs fast, read-only access to another contract's state.
How this skill works
Define storage mapper signatures that take the target ManagedAddress as the first parameter and use #[storage_mapper_from_address("key")] with the exact storage key string. Calls return mapper objects tied to the target address; reading them performs a storage read (not a contract call). Additional mapper parameters become part of the composite key, and results are only valid when both contracts are in the same shard.
When to use it
- You need low-cost, read-only access to another contract’s state
- Both contracts are guaranteed to be on the same shard
- You can identify the exact storage key name(s) in the target contract
- You want to avoid proxy call gas and async flow overhead
- You are aggregating or validating on-chain data across contracts
Best practices
- Always match the storage key string exactly as declared in the target contract
- Check mapper.is_empty() before using get() to detect missing keys or cross-shard returns
- Validate both contracts are on the same shard before reading to avoid silent defaults
- Use this pattern only for read-only requirements; it cannot write or trigger target logic
- Prefer reading source code or the ABI to discover exact key names and parameter encodings
Example use cases
- Read a token balance from an ESDT contract using the target address and TokenIdentifier to aggregate balances
- Query a boolean config flag (e.g., is_active or paused) from a controller contract without invoking logic
- Pull a composite rate or tiered parameter (asset, tier) from a pricing contract for on-chain calculations
- Implement a multi-contract dashboard or indexer that consolidates state with minimal gas overhead
- Validate external contract state inside access-control checks before performing local actions
FAQ
Cross-shard reads return empty/default values (e.g., 0 or false) silently — no error is thrown. Always check shard equality or mapper.is_empty().
How do I find the correct storage key names?
Read the target contract source for #[storage_mapper("key")] annotations or inspect the contract's .abi.json, which lists storage keys and parameter encodings.