# Mass exit API and CLI reference · Chromia Docs (concept)

> This topic summarizes key CLI commands, Rell queries, and EVM contract calls used throughout the mass exit flow.

Source: https://docs.chromia.com/ecosystem/bridge/mass-exit/reference/

# Mass exit API and CLI reference

On this page

* [EVM contract functions](#evm-contract-functions)
* [Trigger mass exit](#trigger-mass-exit)
* [Trigger with historical validators](#trigger-with-historical-validators)
* [Withdraw via snapshot](#withdraw-via-snapshot)
* [Complete in-progress withdrawal](#complete-in-progress-withdrawal)
* [Chromia CLI and queries](#chromia-cli-and-queries)
* [Get account state proof](#get-account-state-proof)
* [Get state slot IDs for user balance](#get-state-slot-ids-for-user-balance)
* [Get state slot IDs for withdrawal](#get-state-slot-ids-for-withdrawal)
* [Get withdrawal by tx + op index](#get-withdrawal-by-tx--op-index)
* [Get withdrawal event proof](#get-withdrawal-event-proof)
* [Cross-Chain recovery](#cross-chain-recovery)
* [Deploy recovery contract](#deploy-recovery-contract)
* [Set recovery contract RID](#set-recovery-contract-rid)
* [Register recovery contract on downstream](#register-recovery-contract-on-downstream)
* [Register it upstream via ICCF on Bridge Chain](#register-it-upstream-via-iccf-on-bridge-chain)

This topic summarizes key CLI commands, Rell queries, and EVM contract calls used throughout the mass exit flow.

## EVM contract functions

### Trigger mass exit

Solidity

```
function triggerMassExit(
  bytes memory blockHeader,     //Recent, verified block header
  bytes[] memory sigs,          //Validator signatures endorsing the header
  address[] memory signers,     //Validator addresses corresponding to the signatures
  Data.ExtraProofData memory extraProof //Additional proof data if needed
```

### Trigger with historical validators

Solidity

```
function triggerMassExitWithHistoricalValidators(
  bytes memory blockHeader,          //Recent, verified block header
  bytes[] memory sigs,               //Validator signatures endorsing the header
  address[] memory signers,          //Validator addresses corresponding to the signatures
  Data.ExtraProofData memory extraProof,//Additional proof data if needed
  address[] memory historicalValidators //Historical validator addresses used for verification
)
```

### Withdraw via snapshot

Solidity

```
function withdrawBySnapshot(
  bytes calldata snapshot,       //Snapshot data capturing the account state
  Data.Proof memory stateProof   //Merkle proof validating the snapshot
)
```

### Complete in-progress withdrawal

Solidity

```
function completeWithdrawalBySnapshot(
  bytes calldata _stateRecord,   //Account state record data (header and withdrawal event hashes)
  uint64 n,                      //Index of the specific withdrawal event in the record
  bytes memory _event,           //Withdrawal event data
  Data.Proof memory stateProof   //Merkle proof for the account state record
)
```

## Chromia CLI and queries

### Get account state proof

Terminal

```
chr query -brid $BRIDGE get_account_state_merkle_proof \
  -- blockHeight=$BLOCK_HEIGHT \
     accountNumber=$ACCOUNT_STATE_SLOT_ID
```

### Get state slot IDs for user balance

Rell

```
val state_slot_ids = hbridge.get_state_slot_ids_for_address(
  beneficiary,//EVM address of the user
  network_id  //Identifier of the EVM network
);
```

### Get state slot IDs for withdrawal

Rell

```
val slot_ids = hbridge.get_withdrawal_state_slot_ids_for_address(
  beneficiary,//EVM address of the user
  network_id  //Identifier of the EVM network
);
```

### Get withdrawal by tx + op index

Rell

```
val withdrawal = hbridge.get_erc20_withdrawal_by_tx(
  tx_rid,   //Rell transaction RID
  op_index  //Operation index within the transaction
);
```

### Get withdrawal event proof

Terminal

```
chr query -brid $BRIDGE get_event_merkle_proof \
  -- eventHash=$WITHDRAWAL_EVENT_HASH
```

## Cross-Chain recovery

### Deploy recovery contract

Terminal

```
npx hardhat deploy:recovery --network <network> \
  --validator-address <VALIDATOR_CONTRACT_ADDRESS>
```

### Set recovery contract RID

Terminal

```
npx hardhat setBlockchainRid:recovery \
  --network <network> \
  --address <RECOVERY_CONTRACT_ADDRESS> \
  --blockchain-rid <DOWNSTREAM_CHAIN_RID>
```

### Register recovery contract on downstream

Terminal

```
chr tx -brid $DOWNSTREAM_CHAIN_RID register_recovery_contract \
  -- $NETWORK_ID x"'$RECOVERY_CONTRACT_ADDRESS'"
```

### Register it upstream via ICCF on Bridge Chain

Terminal

```
chr tx -brid $BRIDGE --iccf-tx $ICCF_TX_RID \
  --iccf-source $DOWNSTREAM_CHAIN_RID \
  register_recovery_contract -- 0
```

[View this page on docs.chromia.com](https://docs.chromia.com/ecosystem/bridge/mass-exit/reference/)Content mirrored from the live docs
