Deploying Smart Contracts
Relix is an EVM-compatible network, so deploying contracts is very similar to working with Ethereum or other EVM chains. The main differences are the network parameters you use during deployment: chain ID, RPC URL, and the native gas token (RLX).
This section walks through a typical deployment flow using common tools, and highlights the parts that are specific to Relix Testnet.
1. Prerequisites
Before you start, you should have:
A wallet connected to Relix Testnet (chain ID 4127)
Some testnet RLX to pay for gas
A basic project using one of the standard EVM toolchains, such as:
Hardhat
Foundry
Remix (for quick experiments)
The examples below assume a simple Solidity contract, but the same process applies to more complex projects.
2. Hardhat: Add Relix as a Network
If you are using Hardhat, add a network entry pointing to the Relix RPC endpoint. In your hardhat.config.ts or hardhat.config.js, define a network similar to this:
import { HardhatUserConfig } from "hardhat/config";
const RELIX_RPC_URL = "https://rpc-testnet.relixchain.com";
const config: HardhatUserConfig = {
solidity: "0.8.24",
networks: {
relixTestnet: {
url: RELIX_RPC_URL,
chainId: 4127,
accounts: [
// private keys of deployment wallets
// e.g. process.env.DEPLOYER_PRIVATE_KEY as string
],
},
},
};
export default config;A few notes:
Store private keys in environment variables or a secure vault, not directly in the config file.
Make sure the deployer address holds enough RLX on Relix Testnet.
Once the network is added, you can deploy using a standard Hardhat script.
3. Hardhat: Example Deployment Script
Create a simple deployment script, for example scripts/deploy.ts:
Then run:
Hardhat will:
Compile the Solidity contracts.
Broadcast the deployment transaction to
https://rpc-testnet.relixchain.com.Wait until the contract is mined on Relix Testnet.
Print the deployed contract address.
4. Foundry: Pointing to Relix
If you prefer Foundry, you can use forge with the Relix RPC URL and chain ID.
In foundry.toml:
Then deploy with:
Here:
--rpc-urlpoints to the Relix Testnet endpoint.--chain 4127ensures transactions are signed for the correct network.The private key should correspond to a wallet funded with RLX on testnet.
5. Remix: Fast Deployment from the Browser
For quick experiments, you can deploy directly via Remix:
Open Remix in your browser.
Write or paste your Solidity contract in a new file.
Compile the contract using the Solidity compiler panel.
In the Deploy & Run tab:
Set Environment to
Injected Provider(MetaMask).Make sure MetaMask is connected to Relix Testnet (4127).
Select your contract from the dropdown and click Deploy.
MetaMask will prompt you to confirm a transaction on Relix Testnet. After you accept:
The transaction will be mined on Relix.
Remix will show the deployed address.
You can interact with the contract directly from Remix or through your dApp.
6. Checking Your Deployment on the Explorer
Regardless of how you deploy, it is good practice to verify the result on the official explorer:
Go to
https://testnet.relixchain.com.Paste the contract address into the search bar.
Confirm:
The deployment transaction is marked as successful.
The contract code is present on the address page.
If the transaction failed:
Check whether the deployer account had enough RLX for the gas cost.
Review constructor arguments or require conditions that might have reverted the deployment.
7. Practical Tips for Relix Deployments
A few habits help make deployments smoother:
Use a dedicated deployer address Keep deployment keys separate from day-to-day wallets whenever possible.
Track environment variables per network For example,
.env.relix.testnetstoring:RELIX_RPC_URLRELIX_DEPLOYER_KEYRELIX_EXPLORER_URL
Test with small contracts first Before deploying complex systems, try a basic contract (like a simple ERC-20) to confirm that your setup, keys, and RPC configuration are all correct.
Record deployed addresses Maintain a small registry file or config (JSON, TOML, or TS) listing:
Contract name
Network (Relix Testnet)
Address
Deployment date and commit hash, if relevant
This makes it easier to coordinate your frontend, backend, and future upgrades.
8. From Testnet to Production
When a mainnet or additional environments are introduced, the migration path is straightforward:
Add a new network entry with the mainnet RPC URL and chain ID.
Keep the same deployment scripts but target the new network.
Rebuild and redeploy only when you are satisfied with how the contracts behave on Relix Testnet.
By keeping your deployment process clean and scripted from the beginning, you can move from experimentation to stable releases on Relix with minimal friction.
Last updated