Deploy Smart Contract

Fantom utilizes a major part of the Ethereum Virtual Machine (EVM) in the backend. Smart contracts are written in Solidity and they can function on Fantom as they do on Ethereum.

To deploy a smart contract, you send a Fantom transaction containing your bytecode without specifying any recipients. You will need FTM tokens to pay the gas fees when deploying smart contracts. To request your testnet FTMs on the testnet, you can use the testnet faucet.

After the contract is deployed, it will be available to all users of the Fantom network. Smart contracts have a Fantom address like other accounts.

Requirements

  • Bytecode (compiled code) of your smart contract

  • FTM for gas costs

  • Deployment script/plugin

  • Access to a Fantom node, either by running your own node or API access to a node

For testnet tokens, you may use the testnet faucet.

Example of smart contract deployment

If you are deploying a smart contract on Fantom for the first time, you may take a look at the example given in the following link:

https://github.com/Fantom-foundation/example-deployment

The repository contains the materials to deploy a smart contract using HardHat and Truffle tools. Instructions to work with the mainnet and testnet are included.

Deployment using Remix

Additional resources

Tools

  • Hardhat: Development environment for editing, compiling, debugging and deploying your smart contracts using the EVM.

  • Truffle: Development environment, testing framework and asset pipeline for blockchains using the EVM.

  • Remix: IDE that’s used to write, compile, debug & deploy Solidity code in your browser.

  • Solidity: Solidity is an object-oriented, high-level language for implementing smart contracts.

  • OpenZeppelin: OpenZeppelin Contracts helps you minimize risk by using battle-tested libraries of smart contracts for Ethereum and other blockchains.

  • thirdweb: Complete Web3 development framework that provides everything you need to connect your applications and games to decentralized networks.

Fantom SONIC Public

Fantom SONIC is an EVM-compatible blockchain showcasing brand-new technology created by Fantom. SONIC Open allows user interactions and smart contracts deployment. To test the network go to the Account Page.

Sonic is compatible with any common Web3 EVM blockchain. If you already have an established tooling for deploying contracts on Fantom Opera, Ethereum, Sepolia, Goerli, or any other EVM based networks, they will work on Sonic as well.

Use our open Web3 API balancer at https://rpcapi.sonic.fantom.network/ as the connection endpoint. The number of requests is limited, so please do not overload the connection.

Here is an example configuration for Hardhat:

require("@nomicfoundation/hardhat-toolbox");

// Replace this private key with your Sonic account private key
const SONIC_PRIVATE_KEY = "YOUR SONIC TEST ACCOUNT PRIVATE KEY";

module.exports = {
  solidity: "0.8.19",
  networks: {
    sonic: {
      url: "https://rpcapi.sonic.fantom.network/",
      accounts: [SONIC_PRIVATE_KEY]
    }
  }
};

Please make sure to use Solidity version 0.8.19 or lower.

To deploy, execute npx hardhat run scripts/deploy.js --network sonic

Last updated

© 2024 Fantom Foundation