OnboardingHow to Use the GX EVM

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

  1. Open MetaMask and click the network selector dropdown
  2. Click Add Network (or Add a network manually)
  3. Enter the following network details:
ParameterValue
Network NameGX Chain EVM
RPC URLhttps://rpc.gx.exchange
Chain IDContact GX docs for the current chain ID
Currency SymbolGX
Block Explorer URLhttps://explorer.gx.exchange
  1. Click Save
  2. 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

  1. Install Hardhat in your project:
npm install --save-dev hardhat
npx hardhat init
  1. Configure hardhat.config.js to include the GX EVM network:
module.exports = {
  solidity: "0.8.27",
  networks: {
    gxevm: {
      url: "https://rpc.gx.exchange",
      accounts: [process.env.PRIVATE_KEY],
    },
  },
};
  1. Deploy your contract:
npx hardhat run scripts/deploy.js --network gxevm

Using Foundry

  1. Deploy with forge:
forge create --rpc-url https://rpc.gx.exchange \
  --private-key $PRIVATE_KEY \
  src/MyContract.sol:MyContract
  1. 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:MyContract

Using Remix

  1. Open Remix IDE
  2. Write or import your Solidity contract
  3. In the Deploy & Run tab, select Injected Provider - MetaMask
  4. Ensure MetaMask is connected to the GX Chain EVM network
  5. Click Deploy and confirm the transaction in MetaMask

GX EVM Block Architecture

The GX EVM uses a dual-block system for optimal performance:

Block TypeIntervalGas LimitUse Case
Fast block1 second2,000,000 gasQuick operations, token transfers, simple calls
Slow block1 minute30,000,000 gasComplex 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:

ContractPurpose
Price OracleRead current mark prices and oracle prices from GX Core
Account StateQuery account balances, positions, and margin data
Market InfoRetrieve 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:

ToolStatus
MetaMaskSupported
HardhatSupported
Foundry (forge/cast)Supported
Remix IDESupported
ethers.jsSupported
viemSupported
The Graph (subgraphs)Planned
OpenZeppelin ContractsSupported

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

  1. Test on testnet first. Use the GX testnet to validate your contracts before deploying to mainnet. See Testnet Faucet for test tokens.
  2. Use established libraries. OpenZeppelin contracts work without modification on GX EVM.
  3. Leverage system contracts. Build DeFi applications that read GX Core price feeds and account state for real-time composability.
  4. Monitor gas limits. Complex operations may need to target slow blocks (1-minute interval, 30M gas limit).