*This is an improvement of the Instant Lottery CIP Draft.*

Every 130 blocks (~21hr 40min) an automated oracle broadcasts data from Bitcoin and Counterparty. The oracle is hard-coded into the Counterparty protocol to make it completely trustworthy.

Some values it can broadcast:

- BTC Fee Ratio
- From each of the 10 previous blocks, take the coinbase tx amount minus block reward (currently 12.5 BTC) to get the total amount of fees. Divide by the block size to get the fee ratio. Broadcast the median value from the ten last blocks.
- Most BTC businesses are hurt by high fees. Opening up for betting on the fee ratios let them hedge against this.
- XCP/BTC Price
- Broadcast the last XCP/BTC price from the DEX
- Can be used to lessen or leverage impact of XCP price volatility
- Random Number
- Derived from last block hash, broadcast a decimal between 0 and 1
- Opens op for any probability, be it a 50-50 coin flip or 1-to-6 dice roll or 1-in-1000 lottery

The oracle will look at the current block height:

- If
`Height mod 130 = 0`

broadcast fee ratio - If
`Height mod 130 = 1`

broadcast xcp price - If
`Height mod 130 = 2`

broadcast random number

These are just three possible values. Any others youâ€™d like to see?

In future updates new broadcast values can be added or existing ones removed.

Relatively few changes are needed to implement this:

- Currently only
`equal / not-equal`

comparisons are possible. New bet types should allow for`greater-than / not-greater-than`

- Currently some BTC dust is sent to Oracle when placing a bet. To save a few pennies, an update should make the Oracle address embedded into the bet message itself
- Currently
`bet expiry`

is the number of blocks until an unmatched bet expires. There should be an option to specify the exact block height for expiry.