Skip to main content

Wrapping as GhostERC20

GhostERC20 tokens are privacy-enabled ERC20 tokens that can be committed and revealed through the Ghost Protocol. They are standard ERC20 tokens with additional mint/burn capabilities for the CommitRevealVault.

How it works

  1. Deploy a GhostERC20 token via the factory
  2. The factory registers the token's ID hash with the CommitRevealVault
  3. Users can commit (burn) the token into the Merkle tree
  4. Users can reveal (mint) the token back using a ZK proof

Deploying a new GhostERC20

Use the GhostERC20Factory at 0x925B548F059C0B8B6CF7168Efb84881252F88C8E:

interface IGhostERC20Factory {
function deployToken(
string calldata name,
string calldata symbol,
uint8 decimals,
bytes32 salt
) external returns (address token);

function computeTokenAddress(
string calldata name,
string calldata symbol,
uint8 decimals,
bytes32 salt
) external view returns (address);
}

Deploy via Foundry

cast send 0x925B548F059C0B8B6CF7168Efb84881252F88C8E \
"deployToken(string,string,uint8,bytes32)" \
"My Token" "MTK" 18 0x0000000000000000000000000000000000000000000000000000000000000001 \
--rpc-url https://testnet.specterchain.com \
--chain-id 5445 \
--private-key $PRIVATE_KEY

Predict the address

cast call 0x925B548F059C0B8B6CF7168Efb84881252F88C8E \
"computeTokenAddress(string,string,uint8,bytes32)(address)" \
"My Token" "MTK" 18 0x0000000000000000000000000000000000000000000000000000000000000001 \
--rpc-url https://testnet.specterchain.com

GhostERC20 interface

GhostERC20 tokens extend standard ERC20 with:

interface IGhostERC20 is IERC20 {
function vault() external view returns (address);
function factory() external view returns (address);
function tokenIdHash() external view returns (bytes32);
function isGhostEnabled() external view returns (bool);

// Only callable by the vault
function mint(address to, uint256 amount) external;
function burn(address from, uint256 amount) external;
}

The mint and burn functions are restricted to the CommitRevealVault contract. Users interact with the token normally (transfer, approve, etc.) and use the vault for privacy operations.

Existing GhostERC20 tokens on testnet

TokenAddress
gUSDC0x65c9091a6A45Db302a343AF460657C298FAA222D
gWETH0x923295a3e3bE5eDe29Fc408A507dA057ee044E81
gLABS0x062f8a68f6386c1b448b3379abd369825bec9aa2

Committing GhostERC20 tokens

To commit a GhostERC20 token, first approve the vault, then call commit():

IERC20(tokenAddress).approve(vaultAddress, amount);
ICommitRevealVault(vaultAddress).commit(tokenAddress, amount, commitment, quantumCommitment);

The vault will call burn(from, amount) on the token, destroying the tokens, and insert the commitment into the Merkle tree.