# FacilitatorAvmSigner

> Protocol for AVM facilitator-side signing operations.

```python
from x402_algorand import FacilitatorAvmSigner
```

```python
class FacilitatorAvmSigner(Protocol)
```

Protocol for AVM facilitator-side signing operations.

Used by x402Facilitator to verify, sign, simulate, and settle transactions.

The facilitator signer is responsible for:
- Providing the fee payer addresses it manages
- Signing fee payer transactions
- Simulating transaction groups
- Sending transaction groups to the network
- Confirming transaction finality

## Methods

### `get_addresses`

```python
def get_addresses() -> list[str]
```

Get all managed fee payer addresses.

**Returns**

- `returns` (`list[str]`):
List of 58-character Algorand addresses that can be used
as fee payers. Enables load distribution across multiple signers.

### `sign_transaction`

```python
def sign_transaction(txn_bytes: bytes, fee_payer: str, network: str) -> bytes
```

Sign a single transaction with the fee payer's key.

**Parameters**

- `txn_bytes` (`bytes`, required):
Unsigned transaction bytes (msgpack encoded).

- `fee_payer` (`str`, required):
Algorand address of the fee payer.

- `network` (`str`, required):
CAIP-2 network identifier.

**Returns**

- `returns` (`bytes`):
Signed transaction bytes (msgpack encoded).

**Raises**

- `ValueError`: If fee_payer is not managed by this signer.

### `sign_group`

```python
def sign_group(
    group_bytes: list[bytes],
    fee_payer: str,
    indexes_to_sign: list[int],
    network: str,
) -> list[bytes]
```

Sign specified transactions in a group with the fee payer's key.

**Parameters**

- `group_bytes` (`list[bytes]`, required):
List of transaction bytes (some signed, some unsigned).

- `fee_payer` (`str`, required):
Algorand address of the fee payer.

- `indexes_to_sign` (`list[int]`, required):
Indexes of transactions the fee payer should sign.

- `network` (`str`, required):
CAIP-2 network identifier.

**Returns**

- `returns` (`list[bytes]`):
List of transaction bytes with fee payer's transactions now signed.

**Raises**

- `ValueError`: If fee_payer is not managed by this signer.

### `simulate_group`

```python
def simulate_group(group_bytes: list[bytes], network: str) -> None
```

Simulate a transaction group to verify it will succeed.

Uses Algorand's simulate endpoint to dry-run the transaction group
without committing it to the network.

**Parameters**

- `group_bytes` (`list[bytes]`, required):
List of signed/unsigned transaction bytes.

- `network` (`str`, required):
CAIP-2 network identifier.

**Raises**

- `Exception`: If simulation fails (contains error message).

### `send_group`

```python
def send_group(group_bytes: list[bytes], network: str) -> str
```

Send a transaction group to the network.

**Parameters**

- `group_bytes` (`list[bytes]`, required):
List of fully-signed transaction bytes.

- `network` (`str`, required):
CAIP-2 network identifier.

**Returns**

- `returns` (`str`):
Transaction ID of the first transaction in the group.

**Raises**

- `Exception`: If sending fails.

### `confirm_transaction`

```python
def confirm_transaction(txid: str, network: str, rounds: int = 4) -> None
```

Wait for transaction confirmation.

Algorand has instant finality - once a transaction is in a block,
it is final and will never be reverted.

**Parameters**

- `txid` (`str`, required):
Transaction ID to confirm.

- `network` (`str`, required):
CAIP-2 network identifier.

- `rounds` (`int`, default `4`):
Maximum rounds to wait (default 4).

**Raises**

- `Exception`: If confirmation times out or transaction fails.

Source: [x402_algorand/signer.py](https://github.com/x402-avm/x402-algorand/blob/main/x402_algorand/signer.py#L85)

Source: https://x402-avm.github.io/reference/python/x402-algorand/facilitator-avm-signer
