multiversx-cross-contract-calls_skill

This skill streamlines cross-contract calls in MultiversX by guiding typed proxies, callbacks, and tx-builder usage for safe, efficient inter-contract

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-calls

  • SKILL.md11.5 KB

Overview

This skill shows how to make cross-contract calls in MultiversX smart contracts using the Tx builder API. It covers transfers, synchronous and asynchronous calls, callbacks, back-transfers handling, and typed proxies to keep calls type-safe. Use it to build robust inter-contract flows that correctly manage payments, gas, and returned tokens.

How this skill works

All cross-contract interactions start from self.tx() and chain builder methods like .to(), .typed() or .raw_call(), payment options, .gas(), .returns(), and an execution method (.sync_call(), .register_promise(), .transfer()). Result handlers capture returned values and back-transfers; callbacks handle async promise results with #[promises_callback]. Always set gas for promises and prefer ReturnsBackTransfersReset to reliably collect returned tokens.

When to use it

  • Calling another contract endpoint on the same shard (synchronous operations).
  • Issuing cross-shard requests that need callbacks or promises (async register_promise()).
  • Sending tokens (EGLD or ESDT) along with a contract call or as a plain transfer.
  • Receiving and processing back-transfers from a callee (swaps, withdrawals).
  • Using generated typed proxies for type-safe, IDE-friendly endpoint calls.

Best practices

  • Prefer typed proxies (.typed(Proxy)) for type safety and clearer arguments/returns.
  • Always use ReturnsBackTransfersReset when expecting back-transfers to avoid stale data.
  • Set explicit .gas() for async register_promise() and .gas_for_callback() for callbacks.
  • Use .returns(ReturnsHandledOrError) with sync_call_fallible() to avoid panics on callee errors.
  • Use .transfer() for plain token sends and reserve .payment() for call-attached payments.

Example use cases

  • Swap tokens on a DEX and forward resulting back-transfers to the original caller.
  • Withdraw liquidity from a pool, then deposit the result into another pool using returned payments.
  • Fire a cross-shard delegation call and mint/ refund tokens in a #[promises_callback] based on success or failure.
  • Deploy a new contract via a typed proxy and capture the new ManagedAddress with ReturnsNewManagedAddress.
  • Make a raw_call to read status or metadata when a proxy is not available.

FAQ

Use sync_call() for same-shard atomic interactions. Use register_promise() for cross-shard async calls and provide gas plus a callback if you need post-processing.

How do I safely collect returned tokens from a call?

Use ReturnsBackTransfersReset in the .returns() chain to reset and return back-transfers. Then process into PaymentVec or individual payments; avoid manual get_back_transfers unless you reset afterwards.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
multiversx-cross-contract-calls skill by multiversx/mx-ai-skills | VeilStrat