# Oracle Update Authorization

**Date**: $(date)  
**Issue**: Oracle contract requires transmitter authorization to update prices

---

## 🔍 Problem

The oracle aggregator contract (`0x99b3511a2d315a497c8112c1fdd8d508d4b1e506`) enforces authorization checks. Only accounts authorized as "transmitters" can call `updateAnswer()`.

**Error Message**: `Aggregator: only transmitter`

---

## ✅ Solution

### Option 1: Use Authorized Transmitter Account

The oracle contract has specific transmitter addresses that are authorized to update prices. You must use one of these accounts:

1. **Identify Transmitter Addresses**: Query the oracle contract to find authorized transmitters
2. **Use Transmitter Private Key**: Set `DEPLOYER_PRIVATE_KEY` to the transmitter account's private key
3. **Run Update Script**: Execute the update script with the transmitter account

### Option 2: Use Oracle Publisher Service (Recommended)

The Oracle Publisher service (VMID 3500) is configured to handle automatic price updates:

1. **Service Configuration**: `/opt/oracle-publisher/.env`
   - Uses the correct aggregator address
   - Configured with authorized transmitter account
   - Automatically updates every 60 seconds

2. **Start Service**:
   ```bash
   ssh root@192.168.11.10
   pct exec 3500 -- systemctl start oracle-publisher
   pct exec 3500 -- systemctl status oracle-publisher
   ```

3. **Verify Updates**:
   ```bash
   # Check service logs
   pct exec 3500 -- journalctl -u oracle-publisher -f
   
   # Query oracle to verify price updates
   cast call 0x3304b747e565a97ec8ac220b0b6a1f6ffdb837e6 \
     "latestRoundData()" \
     --rpc-url https://rpc-http-pub.d-bis.org
   ```

### Option 3: Manual Update with Authorized Account

If you need to manually update the oracle:

1. **Get Authorized Transmitter Address**:
   ```bash
   # Query oracle contract for transmitter addresses
   cast call 0x99b3511a2d315a497c8112c1fdd8d508d4b1e506 \
     "transmitters(uint256)" \
     0 \
     --rpc-url https://rpc-http-pub.d-bis.org
   ```

2. **Use Transmitter Account**:
   ```bash
   export DEPLOYER_PRIVATE_KEY="0x..." # Transmitter account private key
   ./scripts/update-all-oracle-prices.sh
   ```

---

## 📋 Current Configuration

- **Oracle Proxy**: `0x3304b747e565a97ec8ac220b0b6a1f6ffdb837e6` (for reading)
- **Oracle Aggregator**: `0x99b3511a2d315a497c8112c1fdd8d508d4b1e506` (for updates)
- **Update Method**: `updateAnswer(uint256)` on aggregator
- **Authorization**: Only transmitter accounts can update

---

## 🔧 Script Status

The `update-all-oracle-prices.sh` script is correctly configured but requires:
- ✅ Correct aggregator address (0x99b3511a2d315a497c8112c1fdd8d508d4b1e506)
- ✅ Correct method signature (updateAnswer(uint256))
- ❌ Authorized transmitter account private key

---

## ✅ Recommended Approach

**Use the Oracle Publisher Service** (VMID 3500) for automatic updates:
- Already configured with correct addresses
- Uses authorized transmitter account
- Automatically updates every 60 seconds
- Handles errors and retries
- Provides monitoring and logging

**Manual updates** should only be used for:
- Initial setup
- Emergency updates
- Testing/debugging

---

**Last Updated**: $(date)

