# MetaMask / Crypto PSP Settings Guide

This document explains how to configure the MetaMask / crypto payment setup in the admin panel of the ADbotix project. It covers where wallet addresses and blockchain settings live, how to update them for a live environment, and what values are required.

## What this guide covers

- Where to set live wallet addresses in the admin panel.
- Where to configure blockchain and WalletConnect settings.
- What values are safe to store in the admin panel.
- A step-by-step live deployment example.
- Important security guidance.

## Important security note

This system does not store MetaMask private keys, seed phrases, or recovery phrases anywhere in the admin panel. The admin panel only stores public wallet addresses and blockchain connection settings.

Never store any private key or secret recovery phrase in the application or its admin screens.

## 1. Admin panel locations for crypto setup

There are two main admin screens involved:

1. `Company Wallets`
   - File: `backend/views/company-wallet/index.php`
   - Purpose: Add or update the platform's public wallet addresses used for deposits and payouts.
   - What to change here: client receive wallet address, payout wallet address, default deposit wallet.

2. `Settings → Blockchain & Wallet`
   - File: `backend/views/settings/index.php`
   - Purpose: Configure blockchain network endpoints, token information, and wallet connection settings.
   - What to change here: RPC URL, explorer URL, explorer API key, USDT contract address, WalletConnect project ID.

## 2. What you change in Company Wallets

In the admin panel, open the `Company Wallets` page.

### Add a new wallet

- Address: The public BSC/MetaMask wallet address, for example `0xABC123...`.
- Label: Friendly name like `Live Deposit Wallet` or `Live Payout Wallet`.
- Purpose:
  - `Deposit` for receiving deposits.
  - `Payout` for making withdrawals.
  - `Both` if the same wallet should serve both roles.
- Default deposit: if this is the wallet that should receive deposits by default, check the default box.

### Example

Add:
- `0xABC123...` with label `Live Receive Wallet`, purpose `Deposit`, and mark it default if it should be the primary deposit address.
- `0xDEF456...` with label `Live Payout Wallet`, purpose `Payout`.

### Maintain wallet records

- You can edit the label and purpose for each wallet.
- You can activate or deactivate wallets.
- You can delete wallets that are not marked as the default deposit wallet.

## 3. What you change in Settings → Blockchain & Wallet

This section controls the infrastructure values used for on-chain deposit detection and wallet connectivity.

### Main fields

- `bsc_rpc_url`
  - The live BSC RPC endpoint for blockchain reads.
  - Example: `https://bsc-dataseed.binance.org`

- `bsc_explorer_api_url`
  - Base URL for BSC explorer API calls.
  - Example: `https://api.bscscan.com/api`

- `bsc_explorer_api_key`
  - API key for explorer queries.
  - Example: a valid BscScan API key.

- `usdt_contract`
  - The USDT BEP-20 contract address on BSC.
  - Example: `0x55d398326f99059fF775485246999027B3197955`

- `usdt_decimals`
  - The token decimals used by USDT on BSC.
  - Default: `18`

- `deposit_confirmations`
  - Number of confirmations required before a detected deposit is treated as confirmed.
  - Example: `12`

- `deposit_amount_tolerance`
  - Allowed amount difference when matching an expected deposit to an on-chain transfer.
  - Example: `1.00`

- `deposit_match_window_hours`
  - How many hours back a pending deposit remains eligible for matching.
  - Example: `48`

- `walletconnect_project_id`
  - Public WalletConnect / Reown project identifier used by the frontend wallet connect flow.
  - This is not a private key.

## 4. Example live deployment workflow

Use the following process when moving the system to live:

1. Collect the client live wallet details:
   - Live receive wallet address.
   - Live payout wallet address.
   - Network choice, typically BSC.
   - Live token contract address, e.g. USDT BEP-20.

2. Go to `Company Wallets` in the admin panel.
   - Add the receive wallet as a `Deposit` wallet.
   - Optionally make it the default deposit wallet.
   - Add the payout wallet as a `Payout` wallet.

3. Go to `Settings → Blockchain & Wallet`.
   - Set the live `BSC RPC endpoint`.
   - Set the `Block explorer API base URL`.
   - Set the `Explorer API key`.
   - Confirm the `USDT contract` address.
   - If needed, set the `WalletConnect / Reown project_id`.

4. Save the settings.

## 5. Deployment considerations

### Prefer environment variables for secrets

The system is designed so environment variables can override admin settings for infrastructure values.

That means in production you should prefer:
- `BSC_RPC_URL`
- `BSC_EXPLORER_API_URL`
- `BSCSCAN_API_KEY`
- `USDT_CONTRACT`
- `WALLETCONNECT_PROJECT_ID`

These should be set on the server or container environment rather than committed to code.

### What the admin panel does not need

The admin panel should never require:
- MetaMask private key
- Secret recovery seed phrase
- Wallet password

It only requires public addresses and network configuration.

## 6. Summary

To update live MetaMask / crypto PSP details in this project:

- Use `Company Wallets` for public wallet addresses and default deposit wallet selection.
- Use `Settings → Blockchain & Wallet` for RPC, explorer, token, and wallet connect configuration.
- Keep private keys and recovery phrases out of the application.

This guide should be used as the live deployment checklist for the admin panel setup.
