Deploying Smart Contracts
The CrossFi Chain supports smart contracts written in Solidity. You can use popular tools like Hardhat and Foundry to deploy your smart contracts.
This page provides guides for each of these tools:
Starter Templates
For a quick start, we provide minimal templates for both Hardhat and Foundry. These templates come pre-configured with CrossFi network settings and a simple "Hello World" contract.
- Hardhat Template: A minimal Hardhat starter project.
- Foundry Template: A minimal Foundry starter project.
Hardhat
Hardhat is a JavaScript/TypeScript-based smart contract development and testing framework.
- Hardhat Template Guide: Learn how to use our starter template.
- All basic functionality of the framework works on CrossFi chain.
For an exhaustive guide on how to make a smart contract on a CrossFi network, we advise you to first go through the official beginner's guide by Hardhat.
After tutorial completion, add CrossFi chain to your hardhat.config.ts and you'll be fully set up to start your building journey on CrossFi chain.
Foundry
Foundry is a high-performance smart contract development framework written in Rust.
- Foundry Template Guide: Learn how to use our starter template.
- All basic functionality of the framework works on CrossFi chain.
- Can be used in pair with Hardhat.
Deploy with Ethereum JSON-RPC
CrossFi is fully compatible with the Ethereum JSON-RPC APIs, allowing you to deploy and interact with smart contracts on CrossFi and connect with existing Ethereum-compatible web3 tooling. This gives you direct access to reading Ethereum-formatted transactions or sending them to the network which otherwise wouldn't be possible on a Cosmos chain, such as CrossFi.
You can connect to the CrossFi Testnet to deploy and test your smart contracts before moving to Mainnet.
Block Explorers
You can use block explorers to view and debug interactions with your smart contracts deployed on CrossFi. Block explorers index blocks and their transactions so that you can search for real-time and historical information about the blockchain, including data related to blocks, transactions, addresses, and more.
- Mainnet Explorer: https://xfiscan.com
- Testnet Explorer: https://test.xfiscan.com
Contract Verification
You can verify your smart contracts using one of two methods:
- Option A: CLI Verification: Using Hardhat or Foundry command-line tools.
- Option B: Web UI Verification: Using the XFI Scan web interface keying in contract details manually.
Detailed instructions for both methods are available in the respective guides:
- Hardhat: Verification Guide
- Foundry: Verification Guide
Quick Links for Web UI
Quick Links for Web UI
If you prefer using the graphical interface ("Option B"), you can access the verification pages here:
- Mainnet: https://xfiscan.com/contract/verify
- Testnet: https://test.xfiscan.com/contract/verify
What you will need for Web UI verification:
- Contract Address
- Compiler Version (exact match with config)
- Optimization settings (Runs/Enabled)
- Flattened source code (for "Single file" method)
Gas Settings
CrossFi uses a fixed gas price strategy. We recommend setting your gas price to 1 gwei for standard transactions. This ensures your transactions are processed efficiently by the network.