How to Build a Smart Contract on Syscoin Using GetBlock

With Syscoin’s support for smart contracts and GetBlock’s seamless integration, you’re equipped to bring innovative ideas to life on the Syscoin blockchain.

In this guide, we’ll walk you through the basic steps of building a Solidity smart contract on Syscoin using Remix and GetBlock’s services.

Prerequisites:

There are only three tools we’ll be using throughout this guide:

  • Web3 Wallet: MetaMask or other cryptocurrency wallet that supports Syscoin;

  • GetBlock API Key: Use your API key provided by GetBlock to access Syscoin’s blockchain programmatically;

  • Development Environment: For demonstration purposes, we’ll use Remix, a simple in-browser IDE for writing EVM-compatible smart contracts.

Step 1: Add Syscoin Mainnet to MetaMask

  1. Get an API Key from GetBlock: Sign up or log in to your GetBlock account and generate your endpoint for Syscoin Mainnet. Copy the link that appears.

The URL will follow this format:

https://sys.getblock.io/YOUR_GETBLOCK_API_KEY/mainnet

In your case, the ‘YOUR_GETBLOCK_API_KEY’ will be replaced with the actual GetBlock API key privately generated for you.

  1. Go to the MetaMask: click on the section where you select networks at the very top and click “Add Network.”
  2. Proceed with “Custom network” or “Add a network manually” if you use the extension and fill in the corresponding sections with inputs as given below:

Network Name: Syscoin Mainnet

RPC URL: RPC endpoint link obtained from your GetBlock account

Chain ID: Check the official GetBlock documentation to get Syscoin Mainnet ChainID and insert it here

Symbol: SYS

Block Explorer URL: https://explorer.syscoin.org/

  1. Save changes. Now you have direct access to the Syscoin blockchain via GetBlock! Ensure your wallet has some SYS tokens to cover gas fees.

Step 2: Crafting Your Smart Contract

  1. Access Remix: Initiate the Remix IDE directly within your browser
  2. Create a New Workspace and a new file with the name of your project (e.g. SampleContract.sol) and open it.
  3. Compose Your Smart Contract: Begin drafting your Solidity smart contract code using the Remix editor.

Below is an example of a simple contract with one variable:

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

contract SampleContract {

uint256 public num;

function setNum(uint256 _num) public {

num = _num;

}

}

Step 3: Set up GetBlock as a Web3 Provider

Modify Remix Configuration as follows:

  1. In Remix, go to the fourth tab “Deploy & Run Transactions” on the left sidebar;
  2. Change the Environment by selecting “Injected Provider - MetaMask”;
  3. Make sure to select the Syscoin Mainnet that we added to our wallet during the first step and confirm the connection.

Step 4: Deploy Your Smart Contract

  1. Run your contract through Compiler:

  2. In the Remix IDE, navigate to the “Solidity Compiler” icon on the left sidebar.

  3. Select the contract you just created and change the version of the compiler to suit the solidity version.

  4. Click the “Compile” button to compile your contract. Enabling auto-compiler saves you from doing it manually

  5. Deploy Your Contract to Syscoin:

  6. Switch to the “Deploy & Run Transactions” tab. Select your compiled contract from the dropdown menu.

  7. Choose your MetaMask wallet account and gas settings.

  8. Click on “Deploy”, confirm the transaction and gas fee in your MetaMask, and wait for the success message to pop up.

Step 5: Interact with Your Smart Contract

After your contract is deployed, you can use Remix to interact with it.

  1. You can call functions, view state variables, and perform transactions directly through the Remix interface.

  2. Use the setNum function to update the contract’s value.

  3. View the updated value by calling the Num function.

  4. Confirm transactions through MetaMask as needed.

By following these detailed steps, you can create your own contract that harnesses Syscoin’s features while benefiting from GetBlock’s user-friendly API. Start exploring the potential of decentralized applications and smart contracts on Syscoin’s mainnet today!

Do not hesitate to reach out in the GetBlock Discord channel with your questions, should you need any help.