NativeAssetHandler
The NativeAssetHandler bridges native GHOST tokens between the EVM execution layer and the Cosmos x/bank module. Deposits burn GHOST by sending it to a dead address, and withdrawals mint new GHOST via a custom chain precompile.
Deployed address: 0xA0bA5389b07BAdDAaE89B8560849774Bf015acc3
How It Works
The Specter chain is a Cosmos SDK chain with an EVM module. The native GHOST token exists in both layers:
- Cosmos side: managed by
x/bankas the native staking/gas denomination. - EVM side: represented as the native
msg.valuecurrency.
To move GHOST into the privacy vault, the handler burns it by transferring to a dead address. To release GHOST from the vault, the handler mints it via a chain-level precompile. This ensures the total supply remains consistent across both layers.
Burn Address
0x000000000000000000000000000000000000dEaD
GHOST sent to this address is effectively destroyed. The Cosmos x/bank module recognizes transfers to this address as burns.
Ghostmint Precompile
0x0000000000000000000000000000000000000808
The 0x0808 address is a stateful precompile built into the Specter chain. When called, it instructs the Cosmos x/bank module to mint new GHOST tokens to the specified recipient. This precompile is only callable by the NativeAssetHandler contract.
Functions
burnNative
function burnNative() external payable
Burns native GHOST by forwarding msg.value to the 0xdead burn address.
Parameters: None (the amount is determined by msg.value).
Access control: Only the CommitRevealVault can call this function.
Behavior:
- Receives GHOST as
msg.value. - Transfers the full
msg.valueto0x000000000000000000000000000000000000dEaD. - The Cosmos layer detects the burn and adjusts supply accounting.
Reverts if:
- Caller is not the authorized vault.
msg.valueis zero.- Transfer to the burn address fails.
mintNativeTo
function mintNativeTo(address recipient, uint256 amount) external
Mints native GHOST to a recipient by calling the 0x0808 ghostmint precompile.
Parameters:
| Name | Type | Description |
|---|---|---|
recipient | address | The address to receive minted GHOST. |
amount | uint256 | The amount of GHOST to mint (in wei). |
Access control: Only the CommitRevealVault can call this function.
Behavior:
- Encodes the mint call:
abi.encodeWithSignature("mint(address,uint256)", recipient, amount). - Calls the
0x0808precompile with the encoded data. - The precompile instructs
x/bankto creditamountGHOST torecipient.
Reverts if:
- Caller is not the authorized vault.
- Amount is zero.
- Precompile call fails (e.g., insufficient chain permissions).
Precompile Details
The 0x0808 ghostmint precompile is a custom stateful precompile registered in the Specter chain's EVM module configuration. It has the following properties:
| Property | Value |
|---|---|
| Address | 0x0000000000000000000000000000000000000808 |
| Type | Stateful precompile |
| Access | Restricted to NativeAssetHandler |
| Gas cost | Fixed 10,000 gas |
| Effect | Calls x/bank keeper's MintCoins + SendCoinsFromModuleToAccount |
The precompile accepts a single function signature:
function mint(address to, uint256 amount) external;
Usage Example
// During a native GHOST commit (called internally by CommitRevealVault):
NativeAssetHandler(handlerAddress).burnNative{value: depositAmount}();
// During a native GHOST reveal (called internally by CommitRevealVault):
NativeAssetHandler(handlerAddress).mintNativeTo(recipientAddress, withdrawAmount);
Security Considerations
- Both
burnNativeandmintNativeToare restricted to theCommitRevealVault. No other contract or EOA can trigger mints or burns through this handler. - The
0x0808precompile itself is restricted at the chain level to only accept calls originating from theNativeAssetHandlercontract address. - The burn-and-mint pattern ensures that GHOST entering the privacy pool is removed from circulation, and GHOST leaving the pool is freshly minted. This breaks any on-chain linkage between depositor and withdrawer.