Fuse Blockchain Developer Quick Start Guide
Welcome to the Fuse Blockchain Developer Quick Start Guide! This guide is designed to help developers like you get up and running quickly with building on the Fuse Blockchain. Whether you’re a seasoned blockchain developer or just getting started, this guide will provide you with the essential information and resources you need to start building on the Fuse network.Network Details
| Fuse Mainnet | Fuse Testnet (Sparknet) | |
|---|---|---|
| Chain ID | 122 | 123 |
| RPC | https://rpc.fuse.io/ | https://rpc.fusespark.io |
| Symbol | FUSE | FUSE |
| Health | https://health.fuse.io/ | https://health.fusespark.io |
| Explorer | https://explorer.fuse.io/ | https://explorer.fusespark.io/ |
| WebSocket | wss://explorer-node.fuse.io/ws | wss://explorernode.fusespark.io/ws |
| Faucet | Stakely | ChainDrop faucet, Stakely faucet |
| Block size | 20,000,000 | 20,000,000 |
| Block speed | 5 seconds | 5 seconds |
| Gas price | 10 GWei | 10 GWei |
Fuse Network Core Contracts
| Name | Contract |
|---|---|
| Core Consensus | 0x3014ca10b91cb3D0AD85fEf7A3Cb95BCAc9c0f79 |
| BlockReward | 0x63D4efeD2e3dA070247bea3073BCaB896dFF6C9B |
| Voting | 0x4c889f137232E827c00710752E86840805A70484 |
Oracles
In the table below are the Supra Smart Contracts deployed on Fuse.| Contract Name | Contract Address | Version |
|---|---|---|
| Supra Router Contract | 0x1daB558F090029580854FbCF8f83ef3Ad8C223b5 | V2 |
| Supra Deposit Contract | 0x7a168e3AE8B701648D4f8F89B5fCD278885eBeFA | V2 |
Fuse SubGraphs
| Name | Description |
|---|---|
| fuse-nft | All NFTs on the Fuse Network |
| fuse-blocks | Blocks details of the network |
| voltage-dex | Voltage DEX subgraph for on-chain trading information |
| fuse-ethereum-amb | Subgraph for Fuse - Ethereum AMB bridge |
| etherem-fuse-amb | Subgraph for Ethereum - Fuse AMB bridge |
Create and Deploy Smart Contracts
Fuse Blockchain is EVM-compatible. Smart Contracts written in Solidity are deployed on the Fuse Chain. Developers can deploy Smart Contracts in development to the Testnet and Smart Contracts going to Production on the Mainnet. Developers have the option to write their Smart Contracts using a variety of build tools: After writing a Smart Contract to deploy to the Fuse Blockchain, developers must add the Fuse Network to MetaMask. You can add Fuse Network to MetaMask using the following guide. We are going to write an example Smart Contract and follow the required steps to deploy it to the Fuse Blockchain using Hardhat. Open a new terminal and run these commands to create a new folder:0xPRIVATE_KEY is used to sign the Transaction from your EOA without needing permission. You must ensure the EOA that owns the Private Key is funded with some Fuse Tokens to pay for Gas when deploying the Smart Contract.
Open a new terminal and deploy the smart contract to the Fuse network:
Connect Smart Contract using FuseBox
FuseBox is an Open-Source Wallet-as-a-Service platform based on Account Abstraction. It is ERC-4337 compliant and allows developers to use a Bundler to collect UserOperations and a Paymaster to sponsor Gas payments for their users, enabling a Gasless experience. FuseBox is available as a TypeScript SDK and a Flutter SDK. It is a middleware infrastructure that connects directly to the fuse blockchain without needing an RPC node provider. It also makes it easy for Web2 developers to start building blockchain applications without the need to understand ABIs. To understand FuseBox, we will build a quick guide to building a UI for the deployed Token Smart Contract using the FuseBox Web SDK. The Smart Contract has several deployed methods for interacting with it. This quickstart guide will focus ontransfer and balanceOf. The respective SDK methods required are:
Step 1: Set Up Your Next.js App
Create a new Next.js app:Step 2: Install Dependencies
Install the required dependencies:Step 3: Run the Development Server
Runnpm run dev to start the development server. Visit http://localhost:3000 to view your application.
Step 4: Import Libraries
Open theindex.tsx file, delete the default code from NextJS. Edit index.tsx file by adding the code below and save it to see the updated result in your browser. First, import the required libraries and put up a default Hello, World! text:
Step 5: Create a Smart Contract Wallet.
To use the SDK in your project, you must create an instance of the FuseSDK class. This class is the key to interacting with the Fuse API using the SDK. Theinit method sets up a wallet and authenticates the user’s provided credentials. It requires a API_KEY from FuseBox. Create an Account and get the API_KEY in the Fuse Developer Console here. When you send a request to the server using this method, it verifies the credentials. If the credentials are valid, developers can use the getSender() to return an address.
To create the Smart Contract Wallet, we will update the code by adding a smartWallet function, and parsing the returned Smart Contract Address to a state variable.
Inside the Home Component, import the useState method:
useEffect hook to prevent too many re-renders:
Step 6: Token Transfers
Transfer Transactions which happen on the Blockchain are state-changing. In Account Abstraction these “Transactions” are called “UserOperations” because they are first sent to an alternate Mempool where they are then Bundled and sent on-chain. FuseBox uses the transferToken method to carry out a UserOperation of transferring a Token from one Address to another. Add another Function transferToken:transferToken method takes in three arguments: tokenAddress, recipient, amount.
Note: SCW is a Smart Contract Wallet Address.
The tokenAddress is the address of the Token which we are sending a specific amount to a receiving address recipient. You can find a list of Token Addresses here: https://explorer.fuse.io/tokens
It is important to mention that when sending a Token, you will parse the token in units to the number of the decimal places which the Token is defined. For example, USDC has 6 decimal places. To send 1 USDC, you parse it thus:
recipient == toValue, amount == amountValue
Update the Form UI to handle the data and submit it: