Skip to content

What is Agoric Orchestration? ​

Agoric's Orchestration SDK allows developers to easily build cross-chain interactions into existing applications or to create novel cross-chain-focused products.


Diagram showing cross-chain interactions through Agoric orchestration

From a developer's perspective, your contract or dapp can coordinate actions across multiple chains without burdening the user to jump through multiple UIs or signing steps. The Orchestration API handles the complexity behind the scenes. This empowers smart contracts to, for example,

Key Orchestration Use Cases

  • Perform Inter-Chain Staking 🌐 Leverage delegated proof-of-stake opportunities on remote Cosmos chains.

  • Automate Multi-Hop Transfers 🚀 Bridge tokens from Ethereum to Stride, then stake them or perform actions on Osmosis.

  • Support Scheduled Operations ⏰ Enable recurring and delayed tasks like rent collection and subscription services through the on-chain Timer Service.

The Orchestration API sits on top of Agoric's novel VM that provides three key elements that make multichain applications possible:

  • Remote account control and transfer: Use the Orchestration APIs to easily create accounts on remote chains, transfer assets, and invoke contracts. Your Agoric contract orchestrates all behavior directly.
  • Multiblock execution with async and await: Agoric applications communicate asynchronously and await responses which may come in the same block or many blocks (or weeks!) later. Contracts simply continue executing when the response arrives, and keep running even across a contract upgrade. See Async Flow for how a plain async function survives an upgrade by deterministic replay.
  • On-chain Timers: Contracts can set timers for regular or scheduled execution, making recurring activities such as subscriptions straightforward to implement.

Agoric's Orchestration APIs simplify controlling accounts on remote chains, moving assets, and using capabilities on any chain the API reaches.

Orchestration API Flow ​

Orchestration allows us to seamlessly create accounts on remote chains by accessing their chain objects. We can then use these chain objects to create accounts, get addresses, and transfer assets between chains. Let's walk through two common scenarios using the Orchestration API:

1. Creating Remote Accounts ​

The following example shows how to create and interact with an account on the Stride chain:

js
// Get Chain objects
const stride = await orch.getChain('stride');

// Create account
const strideAccount = await stride.makeAccount();

// Get address (getAddress is synchronous, so no await)
const strideAddr = strideAccount.getAddress();

2. Cross-Chain Asset Transfers and Staking ​

This example demonstrates a complete flow of transferring and staking assets across multiple chains. transfer takes the destination first (transfer(destination, amount)):

js
// Transfer funds from Osmosis to Agoric
const osmoToAgoricTransfer = await osmoAccount.transfer(agoricAddr, amount);

// Forward funds from Agoric to Stride
const agoricToStrideTransfer = await agoricAccount.transfer(strideAddr, amount);

// Delegate to a validator on Stride using the typed `delegate` method
const strideValidator = {
  chainId: 'stride-1',
  value: 'stridevaloper1...',
  encoding: 'bech32',
};
await strideAccount.delegate(strideValidator, amount);

// Transfer staked tokens back to user's Osmosis address
const finalTransfer = await strideAccount.transfer(userOsmoAddress, amount);

delegate (and its counterparts undelegate, redelegate, withdrawReward(s)) is one of the typed StakingAccountActions available on any Cosmos account; prefer them over the lower-level executeEncodedTx(msgs) escape hatch, which submits raw encoded protobuf messages and should only be needed for message types that do not yet have a typed method.

These examples demonstrate how Orchestration enables seamless cross-chain operations while abstracting away the underlying complexity. Developers can focus on building their applications' logic while the Orchestration API handles the intricate details of cross-chain communication. For more details, check out the code of several working examples, and their unit tests. We will walkthrough the code of a couple of these examples here. Beyond the two contracts walked through there, the same package includes more recent examples worth reading directly from source: swap-anything (a generalized swap across chains), axelar-gmp (calling EVM contracts via Axelar's General Message Passing), and the flagship products built on Orchestration, Fast USDC and the YMax portfolio contract.