Deploy Smart Contracts With GetBlock

In this guide, we will walk you through the steps of using Remix, MetaMask, and GetBlock RPC endpoints, popular developer tools, to create and deploy a simple smart contract on Fantom. Note that this tutorial will use the Fantom testnet, but the steps remain the same for the mainnet.


Before we begin, make sure you have the following:

  • MetaMask or another Web3 wallet

  • Remix: an online IDE used to write, compile, deploy, and debug Solidity code

  • GetBlock API key: GetBlock provides access to RPC endpoints for various blockchain networks, including Fantom

    • To obtain an API key from GetBlock, register on and find the API key in your account

  • GetBlock RPC endpoint

    • To obtain an RPC endpoint from GetBlock, register on and add a new endpoint by choosing Fantom as the protocol and testnet as the network

Create Contract

A) Configure MetaMask to connect to Fantom using GetBlock RPC endpoints

  1. Open MetaMask and set a custom network with the following details:

    1. Network name: Fantom Opera Testnet

    2. New RPC URL: the GetBlock RPC endpoint you created

    3. ChainID: Obtain the ChainID for Fantom from GetBlock documentation or API (e.g. 4002)

    4. Symbol: FTM

B) Get test tokens on the Fantom testnet

  1. Input your MetaMask wallet address

  2. Complete the CAPTCHA and request the testnet FTM

C) Connect Remix with the Fantom network using GetBlock RPC endpoints

  1. Go to the Remix website

  2. On the Remix home page, choose the Solidity environment

  3. With the Fantom network selected in MetaMask, go to Remix and click the Deploy and Run Transactions button on the left side, which is the fourth button

  4. In the Remix environment section, select Custom - External HTTP Provider and enter the GetBlock RPC endpoint URL you created for Fantom

D) Create a smart contract

  1. Click the File Explorer button on the left side on Remix, which is the first button

  2. Right click and choose New File to create a new Solidity file

  3. Enter the file name as "SimpleStorage.sol"

  4. Copy and paste the following example Solidity code into the SimpleStorage.sol file:contract SimpleStorage {

    uint storedData;

    function set(uint x) public {
        storedData = x;

    function get() public view returns (uint) {
        return storedData;

E) Compile the smart contract

  1. Click the Solidity Compiler button on the left side, which is the third button

  2. Enable auto-compile for convenience

  3. Click the Compile SimpleStorage.sol button

  4. Check for the green sign indicating successful compilation

F) Deploy the smart contract on the Fantom testnet using Remix

  1. Click the Deploy and Run Transactions button on the left side, which is the fourth button

  2. Select the SimpleStorage.sol contract from the dropdown menu

  3. Click the Deploy button

  4. Confirm the transaction in the MetaMask pop-up window

  5. Once confirmed, you will see a message at the bottom right indicating the pending creation of the SimpleStorage contract

  6. You can click on the transaction line or the debug button to view more details of the transaction

  7. Copy the transaction hash for future reference

G) Explore the Fantom Explorer

  1. Use the Fantom Explorer to explore transactions and contracts on the Fantom network

  2. Paste the transaction hash into the search field at the top of the screen to view the details of your transaction

H) Interact with the deployed smart contract

  1. In Remix, under the Deploy and Run Transactions section, expand the SimpleStorage contract by clicking the > symbol

  2. The orange buttons represent functions that change information on the blockchain (state changes) and require gas to execute

  3. The blue buttons represent read-only functions that do not modify the blockchain and do not require gas

  • Get function

    1. Click the Get button to retrieve the stored value, but since we have not set any value yet, it will return the default value

  • Set function

    • Enter a value in the field next to the Set button

    • Click the Set button

    • Confirm the transaction in the MetaMask pop-up window

    • Wait for the transaction to be confirmed

    • After confirmation, you can check the transaction details in the bottom-right section

Congratulations! You have learned how to use Remix, MetaMask, and GetBlock RPC endpoints to create and deploy a smart contract on Fantom.

This guide demonstrates the compatibility of Ethereum developer tools with Fantom, providing you with options for building decentralized applications on both platforms.

If you have any feedback or questions, you may ask them in the GetBlock Discord channel.

Last updated

© 2024 Fantom Foundation