Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions p2p/12.oracle/Node/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RPC_URL=http://localhost:8545
CONTRACT_ADDRESS=contrat-address
COIN_GEKKO_API_KEY=your-coin-gekko-api-key
59 changes: 59 additions & 0 deletions p2p/12.oracle/Node/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"os"
)

type Config struct {
// Ethereum RPC URL (ex: http://localhost:8545 or Infura/Alchemy)
RPCURL string

// Oracle contract address
ContractAddress string

// Node private key (without 0x prefix)
PrivateKey string

// CoinGecko coin IDs to track
Coins []string

// Submission interval in seconds
SubmissionInterval int

// HTTP server port
HTTPPort string

// CoinGecko API Key
CoingeckoApiKey string
}

func LoadConfig() *Config {
rpcURL := os.Getenv("RPC_URL")
if rpcURL == "" {
rpcURL = "http://localhost:8545" // Default to local Anvil/Hardhat
}
contractAddr := os.Getenv("CONTRACT_ADDRESS")
if contractAddr == "" {
contractAddr = "0x5FbDB2315678afecb367f032d93F642f64180aa3" // Default Anvil first deployment
}

privateKey := os.Getenv("PRIVATE_KEY")
if privateKey == "" {
// Default Anvil test key (DO NOT USE IN PRODUCTION)
privateKey = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
}

httpPort := os.Getenv("HTTP_PORT")
if httpPort == "" {
httpPort = ":8080"
}

return &Config{
RPCURL: rpcURL,
ContractAddress: contractAddr,
PrivateKey: privateKey,
Coins: []string{"ethereum"},
SubmissionInterval: 20,
HTTPPort: httpPort,
}
}
34 changes: 34 additions & 0 deletions p2p/12.oracle/Node/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module oracle-node

go 1.24.0

require (
github.com/ethereum/go-ethereum v1.16.7
github.com/joho/godotenv v1.5.1
)

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
github.com/consensys/gnark-crypto v0.18.0 // indirect
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.36.0 // indirect
)
214 changes: 214 additions & 0 deletions p2p/12.oracle/Node/go.sum

Large diffs are not rendered by default.

Loading
Loading