How to Use the GX EVM
GX Chain includes a full Ethereum Virtual Machine (GX EVM) alongside the native GX Core execution environment. This guide explains how to connect to the GX EVM, deploy smart contracts, and interact with on-chain applications.
What Is the GX EVM?
The GX EVM is a complete EVM implementation powered by an EVM-compatible runtime (built in Rust). It runs as part of the GX Chain dual-engine architecture, sharing consensus with GX Core. Any Solidity smart contract that works on Ethereum will work on the GX EVM without modification.
Key characteristics:
- Full Solidity and Vyper smart contract support
- Standard Ethereum JSON-RPC interface
- Dual-block architecture: fast blocks (1 second, 2M gas limit) and slow blocks (1 minute, 30M gas limit)
- Same wallet keys as Ethereum — your MetaMask private key works natively
- Read access to GX Core state (prices, positions, balances) via system contracts
Connect MetaMask to GX EVM
Add the GX EVM Network
- Open MetaMask and click the network selector dropdown
- Click Add Network (or Add a network manually)
- Enter the following network details:
| Parameter | Value |
|---|---|
| Network Name | GX Chain EVM |
| RPC URL | https://rpc.gx.exchange |
| Chain ID | Contact GX docs for the current chain ID |
| Currency Symbol | GX |
| Block Explorer URL | https://explorer.gx.exchange |
- Click Save
- Switch to the GX Chain EVM network in the MetaMask dropdown
Verify Connection
Once connected, your MetaMask wallet should display your GX balance on the GX EVM. If you have deposited funds through GXVault and bridged to the EVM, they will appear here.
Deploy a Smart Contract
The GX EVM supports all standard Ethereum development tools.
Using Hardhat
- Install Hardhat in your project:
npm install --save-dev hardhat
npx hardhat init- Configure
hardhat.config.jsto include the GX EVM network:
module.exports = {
solidity: "0.8.27",
networks: {
gxevm: {
url: "https://rpc.gx.exchange",
accounts: [process.env.PRIVATE_KEY],
},
},
};- Deploy your contract:
npx hardhat run scripts/deploy.js --network gxevmUsing Foundry
- Deploy with
forge:
forge create --rpc-url https://rpc.gx.exchange \
--private-key $PRIVATE_KEY \
src/MyContract.sol:MyContract- Verify on the GX Chain block explorer:
forge verify-contract --chain-id <GX_CHAIN_ID> \
--rpc-url https://rpc.gx.exchange \
<DEPLOYED_ADDRESS> src/MyContract.sol:MyContractUsing Remix
- Open Remix IDE
- Write or import your Solidity contract
- In the Deploy & Run tab, select Injected Provider - MetaMask
- Ensure MetaMask is connected to the GX Chain EVM network
- Click Deploy and confirm the transaction in MetaMask
GX EVM Block Architecture
The GX EVM uses a dual-block system for optimal performance:
| Block Type | Interval | Gas Limit | Use Case |
|---|---|---|---|
| Fast block | 1 second | 2,000,000 gas | Quick operations, token transfers, simple calls |
| Slow block | 1 minute | 30,000,000 gas | Complex computation, contract deployment, batch operations |
Transactions are automatically routed to the appropriate block type based on gas requirements.
System Contracts
The GX EVM includes system contracts that provide read access to GX Core state:
| Contract | Purpose |
|---|---|
| Price Oracle | Read current mark prices and oracle prices from GX Core |
| Account State | Query account balances, positions, and margin data |
| Market Info | Retrieve available markets, funding rates, and open interest |
These system contracts are pre-deployed at fixed addresses and updated by the consensus layer. They enable EVM-based DeFi applications to compose with GX Core trading data.
Supported Tooling
The GX EVM is compatible with the standard Ethereum toolchain:
| Tool | Status |
|---|---|
| MetaMask | Supported |
| Hardhat | Supported |
| Foundry (forge/cast) | Supported |
| Remix IDE | Supported |
| ethers.js | Supported |
| viem | Supported |
| The Graph (subgraphs) | Planned |
| OpenZeppelin Contracts | Supported |
Gas and Fees
Gas on the GX EVM is denominated in GX. You need a small GX balance to pay for transaction fees on the EVM. Gas prices are significantly lower than Ethereum mainnet due to GX Chain’s industry-leading throughput.
Best Practices
- Test on testnet first. Use the GX testnet to validate your contracts before deploying to mainnet. See Testnet Faucet for test tokens.
- Use established libraries. OpenZeppelin contracts work without modification on GX EVM.
- Leverage system contracts. Build DeFi applications that read GX Core price feeds and account state for real-time composability.
- Monitor gas limits. Complex operations may need to target slow blocks (1-minute interval, 30M gas limit).