> For the complete documentation index, see [llms.txt](https://docs.astralbeam.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.astralbeam.io/operators/casper-commands.md).

# Casper Commands

Query Casper Network contract state. These commands are read-only and do not require a private key.

## Usage

```bash
bridge-cli casper <Contract> [method] [args...]
```

**Contracts (case-sensitive):**

* `EthClient` - Block header storage and relayer management
* `TokenFactory` - Token bridging operations and mappings
* `BridgedToken` - CEP-18 token queries

**Important:** Contract names must be exactly as shown above. Using `eth_client` or `token_factory` will not work.

## Interactive Help

When you run a contract command without a method, the CLI displays available methods grouped by category:

```bash
bridge-cli casper EthClient
```

Output:

```
EthClient Methods:

Relayer Info:
  get_threshold         - Get required signature threshold
  get_relayer_count     - Get number of authorized relayers
  get_authorized_relayers - Get list of all relayer addresses
  is_eth_relayer <addr> - Check if address is authorized relayer
  get_eth_relayer <idx> - Get relayer address by index

Block Data:
  get_latest_block      - Get latest submitted block number
  is_block_known <num>  - Check if block has been submitted
  get_block_hash <num>  - Get block hash for block number
  get_state_root <num>  - Get state root for block number
  get_receipts_root <num> - Get receipts root for block number
```

***

## EthClient Commands

### Relayer Information

```bash
# Get signature threshold
bridge-cli casper EthClient get_threshold

# Get number of relayers
bridge-cli casper EthClient get_relayer_count

# Get all authorized relayers
bridge-cli casper EthClient get_authorized_relayers

# Check if address is a relayer
bridge-cli casper EthClient is_eth_relayer 0x1234...

# Get relayer by index
bridge-cli casper EthClient get_eth_relayer 0
```

### Block Data

```bash
# Get latest submitted block number
bridge-cli casper EthClient get_latest_block

# Check if a block is known
bridge-cli casper EthClient is_block_known 5000000

# Get block hash
bridge-cli casper EthClient get_block_hash 5000000

# Get state root
bridge-cli casper EthClient get_state_root 5000000

# Get receipts root
bridge-cli casper EthClient get_receipts_root 5000000
```

**Example Output:**

```bash
$ bridge-cli casper EthClient get_threshold
Result: 3

$ bridge-cli casper EthClient get_latest_block
Result: 5100000

$ bridge-cli casper EthClient is_block_known 5000000
Result: true
```

***

## TokenFactory Commands

### Contract Status

```bash
# Check if contract is paused
bridge-cli casper TokenFactory is_paused

# Get current burn nonce
bridge-cli casper TokenFactory get_burn_nonce

# Get locked amount per chain
bridge-cli casper TokenFactory get_locked_per_chain <chain_id> <erc20_address>
```

### Token Mappings

```bash
# Get CEP-18 address for an ERC-20 token
bridge-cli casper TokenFactory get_cep18_for_chain <chain_id> <erc20_address>

# Get ERC-20 address for a CEP-18 token
bridge-cli casper TokenFactory get_erc20_address <cep18_hash> <chain_id>

# Get total bridged amount for a token (by ERC-20 address)
bridge-cli casper TokenFactory get_total_bridged <erc20_address>

# Check if an event has been processed (by event hash)
bridge-cli casper TokenFactory is_event_processed <event_hash>
```

### Native Token Operations

```bash
# Get total locked native tokens
bridge-cli casper TokenFactory get_total_locked <chain_id>

# Get native lock nonce
bridge-cli casper TokenFactory get_native_lock_nonce
```

**Example Output:**

```bash
$ bridge-cli casper TokenFactory is_paused
Result: false

$ bridge-cli casper TokenFactory get_burn_nonce
Result: 42

$ bridge-cli casper TokenFactory get_cep18_for_chain 11155111 0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238
Result: hash-62d62d5cb43d095b9096ecfe3a3f2bd4d2a1df4020cd9cda94594edb77fedf38
```

***

## BridgedToken Commands

Query CEP-18 token information:

```bash
# Get token name
bridge-cli casper BridgedToken name <token_hash>

# Get token symbol
bridge-cli casper BridgedToken symbol <token_hash>

# Get token decimals
bridge-cli casper BridgedToken decimals <token_hash>

# Get total supply
bridge-cli casper BridgedToken total_supply <token_hash>

# Get balance for an account
bridge-cli casper BridgedToken balance_of <token_hash> <account_hash>

# Get allowance
bridge-cli casper BridgedToken allowance <token_hash> <owner> <spender>
```

**Example:**

```bash
$ bridge-cli casper BridgedToken balance_of \
    hash-62d62d5cb43d095b9096ecfe3a3f2bd4d2a1df4020cd9cda94594edb77fedf38 \
    account-hash-abc123...

Result: 1000000000
```

***

## Examples

### Check Bridge Status

```bash
#!/bin/bash
# Check overall bridge status on Casper

echo "=== EthClient Status ==="
echo "Threshold: $(bridge-cli casper EthClient get_threshold)"
echo "Relayers:  $(bridge-cli casper EthClient get_relayer_count)"
echo "Latest Block: $(bridge-cli casper EthClient get_latest_block)"

echo ""
echo "=== TokenFactory Status ==="
echo "Paused: $(bridge-cli casper TokenFactory is_paused)"
echo "Burn Nonce: $(bridge-cli casper TokenFactory get_burn_nonce)"
```

### Query Token Balance

```bash
#!/bin/bash
USDC_HASH="hash-62d62d5cb43d095b9096ecfe3a3f2bd4d2a1df4020cd9cda94594edb77fedf38"
MY_ACCOUNT="account-hash-abc123..."

echo "USDC Balance: $(bridge-cli casper BridgedToken balance_of $USDC_HASH $MY_ACCOUNT)"
```

***

## Notes

* All queries are read-only and do not require signing keys
* Contract hashes can be specified with or without the `hash-` prefix
* Account hashes can be specified with or without the `account-hash-` prefix
* For admin operations (pause, unpause, add relayers), use `bridge-cli admin casper-*` commands


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.astralbeam.io/operators/casper-commands.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
