Smart contract deployment on Fantom: Opera and Sonic turnkey

Migrating contracts to mainnet is the stage where mistakes are most costly: states are lost, logic breaks, services stop. We deploy smart contracts on Fantom turnkey — from preparation to post-deployment verification. Our engineers manage the project end to end, so launch is predictable and without downtime.

Blockchain Development Services

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1375
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1349
  • B2B Advance company logo design
    B2B Advance company logo design
    794
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1087
  • AIDER company logo development
    AIDER company logo development
    1032
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1129

Fantom smart contract deployment: where it breaks and why

Publishing a contract on the Fantom network looks like a single command, but this is exactly where errors invisible in the test environment surface.

Below: where Fantom smart contract deployment most often breaks and why teams find out about the problem only after the code has gone to mainnet.

First cause — mismatch of compiler version and optimization settings between the local build and publication. The bytecode turns out different, the deployed code does not match the source submitted for verification, and verification stops passing.

The second common contract publication error — an unhandled exception in the constructor or in a connected library: the transaction reverts entirely, and the spent gas is not refunded.

A separate group — write operations. If the gas limit is set by eye, a state-changing call fails with a message that there is not enough gas for the operation, although reading the same contract passes.

Reading does not change state and costs a multiple less, while writing to storage is the most expensive part of the call, and the margin for it is calculated separately.

Add to this the difference between Opera and Sonic: the rules for paying for data storage differ in these networks, and a parameter selected for one quietly fails in the other.

The most expensive scenario — the contract deployed to the wrong place.

The address is determined by the sender's address and the sequence number of their transaction, so republishing from the same key gives a new address, while the client side, scripts, and proxy continue to look at the old one.

External integrations work with outdated code, and the discrepancy surfaces from the data, not at the deployment stage.

All four points are closed by process, not by one engineer's attentiveness: reproducible build, calculating gas for writes, and explicitly passing the address into configuration. That is what we will discuss next.

What changes after managed deployment

Managed contract deployment turns the release of changes from a manual operation into a reproducible process: the build comes from a fixed repository state, checks are run on a local copy of the network, and only then does the code go to mainnet.

The time to roll out a change is measured in tens of minutes instead of days waiting for a window, and identically for the Opera and Sonic branch networks Fantom — the only difference remains in deployment parameters.

The first class to go is failures related to the human at the terminal: wrong network, wrong library address, missed initialization, republishing over a working version. Such errors are not caught by review because they manifest at the moment of signing.

When deployment is performed by the same verified scenario with fixed arguments and a quorum of keys instead of a single signature, the probability of error drops to zero, not "decreases."

Logic and storage are separated: an upgrade changes the implementation behind the proxy, while state stays in place.

Therefore, moving a contract to a new version does not require stopping the service and re-uploading data — wallets and integrations continue to work at the same addresses.

Rollback is also not an emergency but switching the pointer to the previous implementation if post-deployment checks show a deviation.

Contract stability rests on observability: the share of successful calls, gas consumption per operation, and contract events go into monitoring with alerts for deviation from the norm.

This gives not "peace of mind" but something concrete: an incident is visible before user requests, not after.

Deployment modes: Opera, Sonic, and Fantom test networks

The same bytecode behaves differently in different networks of the family: the network identifier, the coin for paying gas, the set of public nodes, and the block explorer address change.

A contract with a hardcoded identifier or external service address will formally deploy but will not work. Therefore, we determine the deployment mode before the build, not after.

Four options that projects actually choose between:

Option When it fits Limitations
Opera, mainnet Industrial launch: token, settlements, public logic Rollback only via contract mechanisms, edits — new version
Sonic, second network of the family New environment on a shared stack and familiar tools Its own addresses, state, and assets — migration needed
Test network Fantom Testing scenarios, roles, and gas payment before launch Different data and external services, behavior diverges
Local test bench on a state copy Fast iterations, regression, upgrade testing Does not reproduce block competition and delays

The route is usually: local test bench, test network, then Opera or Sonic — the build and set of checks are the same at all steps. We put network identifiers, node addresses, and keys into configuration, so switching does not require code edits.

The comparison of deployment networks becomes substantive: what has been tested, what class of errors is closed, and what remains for the main launch.

How contract migration works: engineering stages

Contract migration in Fantom is not republishing code but moving rights, roles, and links between contracts. A mistake in deployment order or initial parameters results in republishing and loss of state, so each stage ends with a verifiable artifact.

  1. Contract audit. We analyze the sources and already deployed addresses: external calls, dependencies on oracles and third-party contracts, owner roles, upgrade mechanisms. We record what is migrated together with the code and what requires reinitialization.
  2. Contract deployment scheme. We build a dependency graph: libraries and auxiliary modules are deployed before the main ones because their addresses are written into constructors. The scheme defines transaction order, initial parameters, and owners.
  3. Artifact build. We compile for the target network, achieve a reproducible build, and save sources and metadata — without this, code verification in the network explorer will not pass.
  4. Testing on the test environment. We run lifecycle scenarios: issuance, transfers, permission changes, pause, emergency shutdown. We compare behavior with the current deployment and close discrepancies before going to mainnet.
  5. Mainnet deployment. We execute according to the scheme, controlling gas consumption and the result of each transaction; after deployment, we verify addresses, rights, and initial state.
  6. Handover of the environment to operations. We hand over addresses, interfaces, the role matrix, the upgrade and rollback policy, and event monitoring settings — the client's team runs the system further without our participation.

What the client receives after publication

Contract publication on the network is not the final point but the moment the system is handed over to operations. The client receives not only an address in the explorer but also a set of artifacts by which their team can develop and maintain the contracts without the author.

  • Contract configurations — files with parameters for the Opera and Sonic networks: dependency addresses, gas limits, values that differ between environments.
  • Contract interaction scheme — a call graph between the main contract, libraries, and external services, with component replacement points marked.
  • Key access policies — separation of the deployment key, administrative and operational keys, multisig signing, rotation order, and backup storage.
  • Contract upgrade policy — upgradeability scheme, change approval procedure, pause window for users, and conditions for releasing a new version.
  • Rollback policy — how to return to the previous implementation, what data is migrated, and who decides on rollback.
  • Contract documentation — description of public methods, events, and invariants that the integration relies on.
  • Role matrix — which employees have access to which management level after handover.

Everything is put into the client's repository with reproduction instructions: deploy a copy of the environment, perform control calls, verify state against expected. Support does not depend on whether the contract author remains on the team.

Case study: contract migration without downtime and state loss

The client — a liquidity pool protocol on Fantom. Contracts were deployed manually: every logic edit meant a new address, manual balance migration, and state reconciliation by logs.

By the third iteration, deployment took up to six minutes, under peak load 3-4% of calls ended in failure, and balance discrepancies between versions were searched manually by logs.

What we did

We moved the logic behind a proxy layer: the address for users and integrations remains unchanged, only the implementation changes. Before switching, we collected a state snapshot and ran the migration on a local copy of the network — with the same data and the same call order.

The switch itself took one block: some calls remained on the old logic, new ones went to the updated one, and rollback is performed by returning the pointer to the previous implementation.

Metrics before and after

Metric Before After
Deployment time 4-6 minutes 20-40 seconds
Failed calls 3-4% less than 0.5%
State migration manually, by logs snapshot and hash verification
Rollback to previous version contract reissue pointer return

State integrity was confirmed by comparing hashes before and after — no discrepancies, user calls were not interrupted. Updates now go out through a proven scenario: snapshot, rehearsal on a network copy, one-block switch.

How does deployment in Opera differ from Sonic?

Both networks are of the same family — EVM-compatible — and the same contract bytecode deploys to Fantom Opera and Sonic without rewriting logic.

The difference starts below the code level: in the fee model for operations, in block limits, and in how the network accounts for the state occupied by the contract. This affects both the load profile after launch and how data storage will have to be organized.

In Opera, fees for operations are calculated according to the familiar scheme: gas for computation plus gas for writing to state, and the block limit restricts transaction volume.

In Sonic, storage accounting has been redesigned — occupied space is paid for separately from computation, and throughput is higher.

For contracts with large write tables, this changes the layout: the storage strategy should be chosen before deployment, not after the first influx of users.

A working contract cannot be migrated in one transaction: addresses and state are independent in the networks, and the different network identifier rules out signature replay.

In practice, the same bytecode is deployed again and data is migrated separately — by state snapshot or via a bridge if continuity of user balances matters.

Therefore, the network is chosen before the first deployment: changing the platform later means migration with all its checks.

Technical questions before starting work

Before starting work, technical teams ask the same questions: what to do with an already deployed contract, how to audit someone else's code, and who gets the keys. Below are direct answers for Fantom networks, without generalities.

How to check a contract if the source code is unavailable?

We compare the bytecode with the published source if it is available; if it is absent, we reconstruct the logic from decompiled code and test behavior with calls on a local copy of the network.

Separately, we record the list of addresses and permissions the contract can change — this shows the real risk surface.

Can a contract be upgraded after publication?

Yes, if the scheme was designed in advance: the logic is moved to a separate contract behind a permanent intermediary address, while state and balances stay in place. If the contract is immutable, upgrade is impossible, and we plan migration with data transfer to a new address.

Where are deployment keys stored?

The key remains with the client on a hardware device; we receive only the address and signed transactions. For critical operations, we set up a multisignature scheme, and separate the administrator role from the account that performed the deployment.

What to do with an already deployed contract?

It does not need to be rewritten: we connect to the existing address, analyze the interface and state. Then — either building a compatible contract on top or migration with transfer of balances and rights, with testing on a network copy before the main transaction.

Let's discuss the task: what is needed to start

Contract work starts not with code but with analyzing the task and source data. The more specific the input, the fewer assumptions in the estimate and the more precise the deployment plan — for the chosen Fantom network, test environment, and future logic upgrades.

To come back with an estimate and plan, rather than general wording, the following minimum is enough:

  • Contract logic and boundaries: what it stores and what actions it allows — deployment, payouts, role-based access, stopping and code upgrades.
  • Roles and rights: who the owner is, who needs administrative powers, who signs transactions, and how we act if a key is lost.
  • Network access handover: nodes and transaction submission services, test accounts, rights to publish and verify code.
  • Existing addresses: already working contracts, if integration is into a live system, and external services for data exchange.
  • Key storage: how operations are currently signed, where secrets are stored, who has access to them, and under what policy.
  • Testing requirements: which scenarios must be covered by tests and what set of checks is needed before release to mainnet.
  • Post-launch support: whether logic upgrades, transaction monitoring, and incident analysis are needed.

We accept access via a secure channel, do not send secrets in chat — we agree on the handover procedure in advance. Then we return with an estimate, a stage-by-stage deployment work plan, and a list of risks with points where your decision is needed.

Describe the task — we will propose timelines and a starting format.