Setup & Staking
PolkaOracle relies on an active network of decentralized reporters to source and submit asset prices. Learn how to run a reporter bot, stake PAS tokens, and participate in consensus.
1. Staking Mechanics
To prevent sybil attacks and ensure accurate reporting, all reporters must stake native PAS tokens in the OracleStaking.sol contract.
- Staking: Call
stake()and send at least 10 PAS (the testnet minimum). You are instantly marked as active. - Unstaking: Call
unstake()to initiate the process. You will immediately stop being eligible to submit prices and enter a cooldown period. - Withdrawal: After the cooldown successfully passes, call
withdrawStake()to return funds to your wallet. - Slashing: The oracle owner or governance can call
slash(reporter, amount)if a node repeatedly submits malicious data or attempts to manipulate the TWAP.
2. Submission Rounds
PolkaOracle updates its feeds when the market deviates or at fixed intervals. When an external trigger (like our backend watcher) opens a new submission round, the following occurs:
1. Round Opens: Reporters detect the request and pull off-chain prices.
2. Submission Window: Reporters have 15 minutes to submit their signed prices via submitPrice(feedId, price).
3. Consensus: The oracle waits until it receives at least minSubmissions. Once met, it calculates the statistical median of all received answers to finalize the price.
3. Price Sources
| Node Identifier | Primary Source | Target Assets |
|---|---|---|
| Reporter 1 | CoinGecko API | DOT, BTC, ETH |
| Reporter 2 | CoinPaprika | DOT, BTC, ETH |
| Reporter 3 | Binance Public API | BTC, ETH |
4. Bot Configuration (.env)
If you are running the Node.js backend reporter, populate the .env file in the backend/ directory with the following keys.
# 1. Network Configuration RPC_URL=https://eth-rpc-testnet.polkadot.io/ CHAIN_ID=420420417 # 2. Reporter Private Key # MUST have PAS tokens and be staked in the OracleStaking contract PRIVATE_KEY=0xYourPrivateKeyHere # 3. Contract Addresses ORACLE_ADDRESS=0xaf781298fE769738eF529816c11C121Ea8887Fc9 STAKING_ADDRESS=0xd2A807a574CAEa31e6DA7102feA1b2071A6a3321 # 4. API Keys (Optional but recommended for high rate limits) COINGECKO_API_KEY=