Skip to content
Coin Press

Reporting from across crypto

What a contract-call swap costs to build

A contract-call swap pays for the code and data its transaction runs, with fees shaped by network demand; developers can compare routes before choosing one.

Coin Press Newsroom3 min read

Abstract cover artwork for this story

A contract-call swap costs the gas needed to run its transaction, and the total rises with the work that transaction asks the chain to do. For developers, that means the swap’s visible fee is only part of the design choice: routing through extra contracts can add execution, while a direct call can fit more easily into an app’s existing flow.

What does a contract-call swap pay for?

It pays for the transaction’s data and execution. Gas is the unit that measures this work on an EVM chain such as Ethereum. A user’s wallet sends one transaction to a contract, which may then call other contracts; those internal calls add to the gas used, but they are part of that same transaction.

The final network fee depends on both the gas used and the price per unit. Ethereum.org describes the fee as gas used multiplied by the effective gas price, which includes the protocol’s base fee and usually a priority fee, or tip. The sender pays in ETH. The market price can change from block to block, so identical swap code can cost different amounts at different times.

More route steps, token transfers, and contract checks can mean more execution. The data sent with a call also has a cost. A simple transfer is therefore a poor estimate for a swap: the contracts, token, route, and current chain state all affect the result. A simulation can estimate the gas for a proposed call, but it cannot lock in the fee market price.

How does a direct vault call compare with a deposit?

A direct vault call lets an app start a swap through a smart contract function, which can make it easier to combine the swap with other on-chain actions. Chainflip’s docs say its Vault route is generally more gas-intensive than using a deposit channel, where a user sends funds to a generated address to start the swap.

The two routes place work in different places. With a direct call, the source-chain transaction carries the swap details in its call data and executes the Vault function. A deposit-channel flow instead uses a regular transfer to a unique address, with swap setup handled through the protocol’s channel process. Chainflip’s guide to choosing and tracking a native swap covers those route choices in more detail.

For an app that needs one atomic user action, the extra gas may be a reasonable cost for composing steps in one transaction. A deposit route can suit a simple send-and-swap flow where lower source-chain gas matters more than on-chain composition.

How should developers estimate and reduce the cost?

Estimate the whole transaction, then compare routes under the same chain conditions. Include the swap call and any app contracts the transaction invokes. If a token approval is needed first, count that as a separate transaction too; an existing allowance may avoid repeating it.

  • Simulate the exact route and token amounts you expect users to submit.
  • Compare gas used as well as fee per gas; they measure different parts of the bill.
  • Remove unnecessary contract hops, checks, or repeated data from the call path.
  • Show users the likely network fee separately from swap fees and destination-chain costs.

A reverted transaction still consumes gas for the work done before it failed, so test failure paths as well as successful ones. The practical choice is simple: use a contract call when composability or a single on-chain action earns its extra execution cost; for a basic swap, prefer the route with less work on the source chain.