GetBlock
In this guide, we will walk you through the steps of using Remix, MetaMask, and GetBlock RPC endpoints, all of which are popular developer tools, to create and deploy a simple smart contract on Opera. Note that this tutorial will use the Opera testnet, but the steps remain the same for the mainnet.
Requirements
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 Opera
To obtain an API key from GetBlock, register on GetBlock.io and find the API key in your account
GetBlock RPC endpoint
To obtain an RPC endpoint from GetBlock, register on GetBlock.io and add a new endpoint by choosing Opera (Fantom) as the protocol and testnet as the network
Create Contract
A) Configure MetaMask to connect to Opera using GetBlock RPC endpoints
Open MetaMask and set up a custom network with the following details:
Network Name: Opera Testnet
New RPC URL: The GetBlock RPC endpoint you created
Chain ID: Obtain the Chain ID for Opera from GetBlock documentation or API (e.g. 4002)
Symbol: FTM
Block Explorer URL: https://explorer.testnet.fantom.network
B) Get test tokens on the Fantom testnet
Visit the Opera Testnet Faucet
Input your MetaMask wallet address
Complete the CAPTCHA and request the testnet FTM
C) Connect Remix with the Opera network using GetBlock RPC endpoints
Go to the Remix website
On the Remix home page, choose the Solidity environment
With the Opera network selected in MetaMask, go to Remix and click the Deploy and Run Transactions button on the left side, which is the fourth button
In the Remix environment section, select Custom - External HTTP Provider and enter the GetBlock RPC endpoint URL you created for Opera
D) Create a smart contract
Click the File Explorer button on the left side on Remix, which is the first button
Right click and choose New File to create a new Solidity file
Enter the file name as "SimpleStorage.sol"
Copy and paste the following example Solidity code into the SimpleStorage.sol file:contract SimpleStorage {
E) Compile the smart contract
Click the Solidity Compiler button on the left side, which is the third button
Enable auto-compile for convenience
Click the Compile SimpleStorage.sol button
Check for the green sign indicating successful compilation
F) Deploy the smart contract on the Opera testnet using Remix
Click the Deploy and Run Transactions button on the left side, which is the fourth button
Select the SimpleStorage.sol contract from the dropdown menu
Click the Deploy button
Confirm the transaction in the MetaMask pop-up window
Once confirmed, you will see a message at the bottom right indicating the pending creation of the SimpleStorage contract
You can click on the transaction line or the debug button to view more details of the transaction
Copy the transaction hash for future reference
G) Use the Testnet Explorer
Use the Explorer to explore transactions and contracts on the Opera network
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
In Remix, under the Deploy and Run Transactions section, expand the SimpleStorage contract by clicking the > symbol
The orange buttons represent functions that change information on the blockchain (state changes) and require gas to execute
The blue buttons represent read-only functions that do not modify the blockchain and do not require gas
Get function
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 Opera.
This guide demonstrates the compatibility of Ethereum developer tools with Opera, providing you with options for building decentralized applications on both platforms.
If you have any feedback or questions, you may ask them on the GetBlock Discord channel.