Skip to main content

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/bank as the native staking/gas denomination.
  • EVM side: represented as the native msg.value currency.

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:

  1. Receives GHOST as msg.value.
  2. Transfers the full msg.value to 0x000000000000000000000000000000000000dEaD.
  3. The Cosmos layer detects the burn and adjusts supply accounting.

Reverts if:

  • Caller is not the authorized vault.
  • msg.value is 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:

NameTypeDescription
recipientaddressThe address to receive minted GHOST.
amountuint256The amount of GHOST to mint (in wei).

Access control: Only the CommitRevealVault can call this function.

Behavior:

  1. Encodes the mint call: abi.encodeWithSignature("mint(address,uint256)", recipient, amount).
  2. Calls the 0x0808 precompile with the encoded data.
  3. The precompile instructs x/bank to credit amount GHOST to recipient.

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:

PropertyValue
Address0x0000000000000000000000000000000000000808
TypeStateful precompile
AccessRestricted to NativeAssetHandler
Gas costFixed 10,000 gas
EffectCalls 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 burnNative and mintNativeTo are restricted to the CommitRevealVault. No other contract or EOA can trigger mints or burns through this handler.
  • The 0x0808 precompile itself is restricted at the chain level to only accept calls originating from the NativeAssetHandler contract 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.