Wrapped GX (WGX)
Wrapped GX (WGX) is an ERC-20 representation of the native GX token on GX EVM. It enables the native gas token to be used within smart contracts that require ERC-20 compatibility.
Overview
| Property | Value |
|---|---|
| Token name | Wrapped GX |
| Symbol | WGX |
| Decimals | 18 |
| Contract address | 0x4200000000000000000000000000000000000001 |
| Standard | ERC-20 (WETH9 pattern) |
WGX follows the same pattern as WETH on Ethereum: deposit native GX to receive WGX, or withdraw WGX to receive native GX.
Why Wrapped GX
The native GX token is used to pay gas fees on GX EVM but is not an ERC-20 token. Many DeFi protocols (AMMs, lending platforms, vaults) require ERC-20 tokens. WGX bridges this gap by providing an ERC-20 wrapper.
Interface
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IWGX {
/// @notice Deposit native GX and receive WGX
function deposit() external payable;
/// @notice Withdraw WGX and receive native GX
/// @param amount Amount of WGX to unwrap (18 decimals)
function withdraw(uint256 amount) external;
// Standard ERC-20 interface
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
event Deposit(address indexed dst, uint256 amount);
event Withdrawal(address indexed src, uint256 amount);
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
}Wrapping GX
Deposit (GX -> WGX)
Send native GX to the WGX contract to receive an equal amount of WGX tokens.
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("https://rpc.gx.exchange");
const wallet = new ethers.Wallet("0xYourPrivateKey...", provider);
const wgxAddress = "0x4200000000000000000000000000000000000001";
const wgx = new ethers.Contract(wgxAddress, [
"function deposit() payable",
"function withdraw(uint256 amount)",
"function balanceOf(address) view returns (uint256)",
], wallet);
// Wrap 1 GX
const tx = await wgx.deposit({ value: ethers.parseEther("1.0") });
await tx.wait();
// Or simply send GX to the contract address
const tx2 = await wallet.sendTransaction({
to: wgxAddress,
value: ethers.parseEther("1.0"),
});
await tx2.wait();from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://rpc.gx.exchange"))
account = w3.eth.account.from_key("0xYourPrivateKey...")
wgx_address = "0x4200000000000000000000000000000000000001"
wgx_abi = [
{"inputs": [], "name": "deposit", "outputs": [], "stateMutability": "payable", "type": "function"},
{"inputs": [{"name": "amount", "type": "uint256"}], "name": "withdraw", "outputs": [], "stateMutability": "nonpayable", "type": "function"},
]
wgx = w3.eth.contract(address=wgx_address, abi=wgx_abi)
# Wrap 1 GX
tx = wgx.functions.deposit().build_transaction({
"from": account.address,
"value": w3.to_wei(1, "ether"),
"gas": 50000,
"nonce": w3.eth.get_transaction_count(account.address),
})
signed = account.sign_transaction(tx)
tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction)
w3.eth.wait_for_transaction_receipt(tx_hash)Withdraw (WGX -> GX)
Burn WGX tokens to receive an equal amount of native GX.
// Unwrap 1 WGX
const tx = await wgx.withdraw(ethers.parseEther("1.0"));
await tx.wait();
// Native GX balance increased by 1.0
const balance = await provider.getBalance(wallet.address);
console.log("GX balance:", ethers.formatEther(balance));Using WGX in Smart Contracts
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "./IWGX.sol";
contract MyVault {
IWGX constant WGX = IWGX(0x4200000000000000000000000000000000000001);
/// @notice Accept GX deposits and wrap them
receive() external payable {
WGX.deposit{value: msg.value}();
}
/// @notice Withdraw GX from the vault
function withdrawGX(uint256 amount) external {
WGX.withdraw(amount);
payable(msg.sender).transfer(amount);
}
/// @notice Get WGX balance held by this contract
function wgxBalance() external view returns (uint256) {
return WGX.balanceOf(address(this));
}
}Gas Costs
| Operation | Gas Cost |
|---|---|
deposit() | ~30,000 |
withdraw(uint256) | ~35,000 |
transfer(address, uint256) | ~50,000 |
approve(address, uint256) | ~45,000 |
Security Notes
- The WGX contract is a system contract deployed at genesis. It cannot be upgraded or paused.
- WGX is always 1:1 backed by native GX held in the contract.
- The contract follows the audited WETH9 pattern used on Ethereum mainnet.