Skip to content

Commit a7b1595

Browse files
authored
Merge pull request #121 from PoCInnovation/workshop-p2p-oracle
Workshop p2p oracle
2 parents d9549f8 + 59cf710 commit a7b1595

32 files changed

Lines changed: 3022 additions & 0 deletions

p2p/12.oracle/Node/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RPC_URL=http://localhost:8545
2+
CONTRACT_ADDRESS=contrat-address
3+
COIN_GEKKO_API_KEY=your-coin-gekko-api-key

p2p/12.oracle/Node/config.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package main
2+
3+
import (
4+
"os"
5+
)
6+
7+
type Config struct {
8+
// Ethereum RPC URL (ex: http://localhost:8545 or Infura/Alchemy)
9+
RPCURL string
10+
11+
// Oracle contract address
12+
ContractAddress string
13+
14+
// Node private key (without 0x prefix)
15+
PrivateKey string
16+
17+
// CoinGecko coin IDs to track
18+
Coins []string
19+
20+
// Submission interval in seconds
21+
SubmissionInterval int
22+
23+
// HTTP server port
24+
HTTPPort string
25+
26+
// CoinGecko API Key
27+
CoingeckoApiKey string
28+
}
29+
30+
func LoadConfig() *Config {
31+
rpcURL := os.Getenv("RPC_URL")
32+
if rpcURL == "" {
33+
rpcURL = "http://localhost:8545" // Default to local Anvil/Hardhat
34+
}
35+
contractAddr := os.Getenv("CONTRACT_ADDRESS")
36+
if contractAddr == "" {
37+
contractAddr = "0x5FbDB2315678afecb367f032d93F642f64180aa3" // Default Anvil first deployment
38+
}
39+
40+
privateKey := os.Getenv("PRIVATE_KEY")
41+
if privateKey == "" {
42+
// Default Anvil test key (DO NOT USE IN PRODUCTION)
43+
privateKey = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
44+
}
45+
46+
httpPort := os.Getenv("HTTP_PORT")
47+
if httpPort == "" {
48+
httpPort = ":8080"
49+
}
50+
51+
return &Config{
52+
RPCURL: rpcURL,
53+
ContractAddress: contractAddr,
54+
PrivateKey: privateKey,
55+
Coins: []string{"ethereum"},
56+
SubmissionInterval: 20,
57+
HTTPPort: httpPort,
58+
}
59+
}

p2p/12.oracle/Node/go.mod

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module oracle-node
2+
3+
go 1.24.0
4+
5+
require (
6+
github.com/ethereum/go-ethereum v1.16.7
7+
github.com/joho/godotenv v1.5.1
8+
)
9+
10+
require (
11+
github.com/Microsoft/go-winio v0.6.2 // indirect
12+
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect
13+
github.com/StackExchange/wmi v1.2.1 // indirect
14+
github.com/bits-and-blooms/bitset v1.20.0 // indirect
15+
github.com/consensys/gnark-crypto v0.18.0 // indirect
16+
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
17+
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
18+
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
19+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
20+
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
21+
github.com/ethereum/go-verkle v0.2.2 // indirect
22+
github.com/fsnotify/fsnotify v1.6.0 // indirect
23+
github.com/go-ole/go-ole v1.3.0 // indirect
24+
github.com/google/uuid v1.3.0 // indirect
25+
github.com/gorilla/websocket v1.4.2 // indirect
26+
github.com/holiman/uint256 v1.3.2 // indirect
27+
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
28+
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
29+
github.com/tklauser/go-sysconf v0.3.12 // indirect
30+
github.com/tklauser/numcpus v0.6.1 // indirect
31+
golang.org/x/crypto v0.36.0 // indirect
32+
golang.org/x/sync v0.12.0 // indirect
33+
golang.org/x/sys v0.36.0 // indirect
34+
)

p2p/12.oracle/Node/go.sum

Lines changed: 214 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)