Skip to main content

What is Wormhole, and how does a cross-chain swap use it?

· · 12 min read
BlockTrader365
Illustration: What is Wormhole, and how does a cross-chain swap use it?

Wormhole is a protocol for passing messages between blockchains. A contract on one chain publishes a message, a set of 19 nodes called Guardians observes it and signs it, and once any 13 of them have signed, a contract on another chain can verify the message without having to follow the source chain itself.

Most people meet Wormhole through a bridge or a cross-chain swap, and most of them never see it. This article explains what it does, what the Wormhole Token Bridge does with your tokens, and the one place in a cross-chain swap where Wormhole shows up in the transaction you sign.

What is Wormhole?​

A smart contract cannot read another chain. Ethereum has no way to check what happened on Solana, and the reverse is just as true: verifying another chain's history directly would take more storage and computation than a contract can afford. Wormhole's own design document states the problem it solves as "enabling contracts on one chain to verify messages from a different chain" (Wormhole, generic message passing).

The answer it chose is a signing committee. Each connected chain has a Wormhole core contract. An application calls it to publish a message. The Guardians, which run nodes connected to every chain in the network, see the message, wait until the chain has reached the level of finality the sender asked for, and sign an attestation of it. The signed attestation is published on Wormhole's peer-to-peer network, and anyone can carry it to a destination chain, where the core contract there checks the signatures.

The Guardian set is fixed and public. Wormhole's security policy gives the numbers (Wormhole, SECURITY.md):

  • There are 19 Guardians in the current set.
  • A super majority, "any 2/3+ quorum of Guardians - 13 of 19", can pass messages, including token value movement, and can pass governance such as contract upgrades and Guardian set changes.
  • A super minority, "any 1/3+ quorum of Guardians - 7 of 19", can censor messages by refusing to sign or to observe a chain.

The arithmetic follows from the fractions: two thirds of 19 is 12.67, so 13 signatures is the smallest number above two thirds; one third of 19 is 6.33, so 7 is the smallest number above one third.

Wormhole deliberately stops at signing. The same design document lists delivery as a non-goal: "Delivering the signed message to the target chain is up to the individual application." That split explains why every product built on Wormhole has its own relayer, solver or "claim" step.

What is a Wormhole VAA?​

The signed message is called a VAA, a Verifiable Action Approval. Its body includes these fields, each set by the Guardians, by the core contract or by the application that published it (Wormhole, generic message passing); it also carries others, such as a timestamp and a nonce:

  • Emitter chain: the chain the message came from, as a Wormhole chain ID, a 16-bit number. The Guardian sets it according to which chain it saw the message on.
  • Emitter address: the contract that published it, written as 32 bytes. An address shorter than 32 bytes, such as a 20-byte EVM address, is padded with zeros on the left.
  • Sequence: a counter the core contract increments for each message from that emitter.
  • Consistency level: how final the source block must be before Guardians sign. On EVM chains, 200 means publish immediately, 201 means the safe block (or finalized where a chain has no safe tag), and 202 means finalized.
  • Payload: the application's own bytes, which Wormhole does not interpret.

The Guardian signatures cover that body. The design document requires that "any given message MUST NEVER result in two different VAAs", and the hash of the body is what a destination uses to refuse a replay.

Wormhole's chain IDs are its own numbers, not the EVM chain IDs a wallet shows. In Wormhole's source, Solana is 1, Ethereum 2, BNB Chain 4, Polygon 5, Avalanche 6, Arbitrum 23, Optimism 24, Base 30 and HyperEVM 47 (Wormhole, sdk/vaa/structs.go). Base's EVM chain ID is 8453 and HyperEVM's is 999; inside a Wormhole message they are 30 and 47.

How does the Wormhole Token Bridge move a token between chains?​

The Token Bridge is an application built on the messaging layer, and the tokens it wraps are the ones token lists label "Portal", as in "Coinbase Wrapped BTC (Portal from Base)". Its design is lock-and-mint (Wormhole, token bridge):

  1. On the token's native chain, the bridge contract locks your tokens in custody and posts a Transfer message to Wormhole.
  2. The Guardians sign it.
  3. Someone posts the VAA to the bridge contract on the destination chain. If the token is native there, the contract releases it from custody; if not, it mints a wrapped representation.
  4. Sending the wrapped token back burns it, and the return message unlocks the original.

The bridge guarantees one wrapped asset per chain for each foreign token, so moving a token from chain A to C directly or by way of B ends in the same wrapped token. Its design also includes an emergency pause for use during an active exploit.

The point that matters to a trader is what the wrapped token is. It is a claim on tokens locked in the bridge, minted by the bridge, at its own contract address. It is not the issuer's token on that chain, even when the two share a symbol.

How does BT365's cross-chain swap code use Wormhole?​

BT365's cross-chain swap code reaches Wormhole only through its numbering. It does not move tokens through the Wormhole Token Bridge.

The swap code has two providers, Mayan and Relay, each behind its own switch; only Mayan's orders carry Wormhole numbering. The code pins which Mayan route families it will accept. The adapter that calls Mayan's SDK asks for quotes with swift: true and fastMctp: true, and with wormhole, mctp, shuttle, gasless and monoChain all set to false. The plain Wormhole route, the one that would deliver a token-bridge transfer, is never requested.

The token list follows the same rule. Mayan's token lists carry same-symbol Wormhole "Portal" wrappers of assets like USDC and USDT, and the route registry's pinned tokens are the issuers' own contracts. Its comments say so directly: Portal wrappers "share symbols with the canonical tokens and are never pinned".

Wormhole's numbering comes in through the order itself. A Swift order, as the code decodes it, carries a trader, a destAddr and a destChainId. The destination chain ID is a 16-bit Wormhole chain ID, the same width as the emitter chain in a VAA, and the destination address is 32 bytes, padded on the left like a Wormhole address. The backend keeps a pinned table of Wormhole IDs for nine chains, and every entry matches Wormhole's own list above.

Before any transaction reaches the user, the server decodes the Swift order inside it and refuses the build if any field disagrees with the request: the destination chain must equal the pinned Wormhole ID of the chosen chain, the destination address must equal the chosen wallet, the trader must equal the source wallet, and the payload type, custom payload, deadline, referrer and minimum output must all match the quote. The transaction must also call Mayan's pinned forwarder contract.

The client checks again. The web app and the Android app each decode the destination from the transaction's calldata, map the Wormhole ID back to a chain, and refuse to ask for a signature on any mismatch. The code comment states the reason: "The destination is fixed inside the signed order; nobody can reroute it afterwards."

This article describes how the code is built. It does not say the cross-chain swap is switched on for your account; that is a feature flag the article does not read.

A worked example: from Base to Arbitrum​

Say a user on Base swaps into a token on Arbitrum, and the quote comes back as a Swift order. (HyperEVM has a Wormhole ID too, 47, but the code routes HyperEVM through a different provider, Relay, so no Swift order is built for it.)

  • The source chain is Base: EVM chain ID 8453, Wormhole chain ID 30.
  • The destination is Arbitrum: EVM chain ID 42161, Wormhole chain ID 23.
  • The user's 20-byte destination address becomes 32 bytes: twelve zero bytes followed by the address, which in hex is 0x, then 24 zeros, then the address's 40 hex characters.

The server reads the order's destChainId. If it is 23 and destAddr is the padded address, the build passes that check. If the order said 30, it would be addressed back to Base, and the server refuses it with DEST_CHAIN_MISMATCH. If it named any other address, the refusal is DEST_ADDR_MISMATCH. If something got past the server, the client's decode would fail the same comparison, with destination_chain_mismatch or destination_mismatch, and the wallet prompt would never open.

The check costs one decode and two comparisons. It matters because a signed order cannot be edited: once signed, the destination in it is where the funds go.

What are the risks and limits of Wormhole?​

You trust the Guardians. Every Wormhole message, and every token-bridge transfer, is only as sound as 13 of 19 signers. Wormhole's security policy is plain that a super majority can pass messages and upgrade contracts, and that 7 Guardians can stop a message by refusing to sign. A swap that uses Wormhole only to name a chain is not trusting it to move value. A token-bridge transfer is.

Finality is the sender's choice. A message signed at consistency level 200 on an EVM chain was published immediately, before the block was safe or finalized. Products that move fast on fresh blocks take a reorg risk that a finalized message does not.

A symbol is not a token. A Portal-wrapped USDC on Ethereum and Circle's USDC on Ethereum share a symbol and are different contracts with different backing. Check the contract address against the issuer's own list before you accept a token.

The honest answer is sometimes "don't sign". If the destination chain or address your wallet shows is not the one you chose, do not sign. Nobody can reroute a signed order, including you.

BT365 is not available in every jurisdiction, and nothing on this page is investment advice. Trading perpetual futures and prediction markets carries risk of loss.