Deploy a smart contract to the Fantom Network

Below are instructions about how to deploy a Solidity smart contract to the Fantom network. The Fantom Network is a blockchain that uses the Ethereum Virtual Machine (EVM) which means it is Solidity compatible. The process to deploy a smart contract outlined below is almost identical to other EVM compatible blockchains.

What is the Fantom Network

Fantom Network is a blockchain that supports smart contracts and staking (instead of POW) for the native FTM token. Fantom built their own consensus algorithm (aBFT consensus algorithm), claims almost instant transfers, highly scalable, proof of stake validator nodes and EVM compatible. Chainlink and Band protocol oracles are integrated in Fantom. For more information about Fantom visit their website.

Fantom smart contract development tools

As a Fantom developer you can use the same development tools that are used for development on Ethereum. You can use Remix, Truffle, MetaMask, etc. to develop on the Fantom blockchain. Check here for a list of Ethereum developer tools.

Configure MetaMask for the Fantom test network

The name of the Fantom test network is Fantom testnet and below I will explain how to configure your MetaMask wallet to connect to the Fantom testnet.

Open MetaMask and select:

  • Settings
  • Network

Deploy a smart contract to the fantom Network MetaMask

Select Add Network

Deploy a smart contract to the fantom Network MetaMask

  • Copy and past the information below in a text editor. It will make it easier to put this information into MetaMask and will prevent the screen from closing on you.
  • Type the below information into MetaMask:
  1. Network Name: Fantom testnet
  2. New RPC Url: https://rpc.testnet.fantom.network/
  3. ChainID: 0xfa2
  4. Symbol: FTM
  5. Block Explorer URL: https://testnet.ftmscan.com/ or https://explorer.testnet.fantom.network

Deploy a smart contract to the fantom Network MetaMask

Now your MetaMask wallet is connected to the Fantom testnet.

If you don’t want to use MetaMask you can use the Fantom web wallet for the test environment.

Fantom faucet for test tokens

Now go to the Fantom faucet and request test FTM tokens. The tokens are sent to your wallet within seconds.

Now that you are connected to the Fantom testnet, your wallet is setup, and you have FTM test tokens try to deploy a smart contract.

Deploy smart contract to the Fantom network

You can use Remix to write Solidity smart contracts and deploy them to the Fantom test network. To test this you can copy the Solidity smart contract code below and give it a try.

//define which compiler to use
pragma solidity ^0.5.0;

//contract name is MyFirstFantomContract 
contract MyFirstFantomContract {


    string private name;
    uint private amount;

//set
    function setName(string memory newName) public {
        name = newName;
    }

//get
    function getName () public view returns (string memory) {
        return name;
    }
    
//set
    function setAmount(uint newAmount) public {
        amount = newAmount;      
    }

//get
    function getAmount() public view returns (uint) {
        return amount;
    }
}

Try it in Remix

Then submit your transaction to the network in Remix. MetaMask will display Fantom Testnet in the upper right corner.

To see the transaction confirm on the Fantom network use their block explorer for the test environment.

Use their block explorer to navigate to your smart contract that was submitted to the test network. To view the contract click on the newly created contract account number on the top left of the screen (the black line in the picture below is blocking the contract account number).

To verify the contract code click on the “Verify and Publish” link in the middle of the screen. The contract verify and publish process is very similar to Ethereum.

Fantom verify and publish a smart contract

Configure MetaMask for the Fantom Mainnet network

The Fantom Mainnet can be configured using the settings below. Copy and past the information below in a text editor.

  • It will make it easier to put this into MetaMask and will prevent the screen from closing on you.
  • Type the below information into MetaMask by adding a new custom RPC. Follow the instructions above for the test network and use the setting below for the Mainnet.

Fantom API URL’s to connect a Web3 program

Fantom GraphQL

Use the link below to connect to the GraphQL on Fantom

Transfer funds from Ethereum to Fantom on the Mainnet

If you have tokens on Ethereum and you want to transfer them to Fantom you can use the AnySwap Bridge. This bridge is a trustless two way transaction channel and you can read more about it here. It takes approximately 12-15 mins for funds to transfer.

  1. Navigate to the Anyswap bridge website 
  2. Connect your wallet
  3. Select the token on the Ethereum chain that you want to move to Fantom chain.
transfer funds to fantom using Anyswap

Run a Fantom validator node

For information on how to setup and run a validator node visit the Fantom validator node page.

Resources

Blockchain Networks

Below is a list of Mainnet and Testnet blockchain networks. Each link contains network configuration, links to multiple faucets for test ETH and tokens, bridge details, and technical resources for each blockchain. Basically everything you need to test and deploy smart contracts or decentralized applications on each chain. For a list of popular Ethereum forums and chat applications click here.

Ethereum test network configuration and test ETH faucet information
Optimistic Ethereum Mainnet and Testnet configuration, bridge details, etc.
Polygon network Mainnet and Testnet configuration, faucets for test MATIC tokens, bridge details, etc.
Binance Smart Chain Mainnet and Testnet configuration, faucets for test BNB tokens, bridge details, etc.
Fanton networt Mainnet and Testnet configuration, faucets for test FTM tokens, bridge details, etc.

Next – How to connect your hardware wallet to MetaMask

Ledger Nano X - The secure hardware wallet

3 thoughts on “Deploy a smart contract to the Fantom Network

Leave a Reply