Update BaudCoin assets (site: baud.cash)
Browse files
miner.py
CHANGED
|
@@ -10,7 +10,7 @@ An AI agent's entry point to the BAUD network on BNB Chain:
|
|
| 10 |
python miner.py mine join the live epoch loop (needs coordinator)
|
| 11 |
|
| 12 |
Configuration comes from environment variables (see SKILL.md):
|
| 13 |
-
BAUD_CONTRACT BEP20 contract address (
|
| 14 |
BAUD_COORDINATOR coordinator API base URL (published at launch)
|
| 15 |
BAUD_RPC BNB Chain JSON-RPC endpoint
|
| 16 |
BAUD_KEYFILE where the wallet keyfile lives
|
|
@@ -29,9 +29,24 @@ from eth_account import Account
|
|
| 29 |
from eth_account.messages import encode_defunct
|
| 30 |
|
| 31 |
RPC = os.environ.get("BAUD_RPC", "https://bsc-dataseed.binance.org")
|
| 32 |
-
CONTRACT = os.environ.get("BAUD_CONTRACT", "")
|
| 33 |
COORDINATOR = os.environ.get("BAUD_COORDINATOR", "")
|
| 34 |
KEYFILE = os.environ.get("BAUD_KEYFILE", "./baud-wallet.json")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
BALANCE_OF_SELECTOR = "0x70a08231" # balanceOf(address)
|
| 37 |
DECIMALS = 18
|
|
@@ -69,6 +84,7 @@ def cmd_init():
|
|
| 69 |
print(f" address : {acct.address}")
|
| 70 |
print(f" keyfile : {KEYFILE} (keep this secret)")
|
| 71 |
print("Fund this address with a small amount of BNB, then run: python miner.py status")
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
# ---------------------------------------------------------------- chain reads
|
|
@@ -99,6 +115,7 @@ def baud_balance(address: str) -> float:
|
|
| 99 |
|
| 100 |
def cmd_status():
|
| 101 |
acct = load_or_create_account()
|
|
|
|
| 102 |
print(f"agent wallet : {acct.address}")
|
| 103 |
print(f"BNB balance : {bnb_balance(acct.address):.6f} BNB")
|
| 104 |
if CONTRACT:
|
|
@@ -107,6 +124,37 @@ def cmd_status():
|
|
| 107 |
print("BAUD balance : set BAUD_CONTRACT to read (published at launch)")
|
| 108 |
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# ---------------------------------------------------------------- mining loop
|
| 111 |
|
| 112 |
def coordinator_handshake(acct) -> dict:
|
|
@@ -192,6 +240,8 @@ def cmd_doctor():
|
|
| 192 |
|
| 193 |
has_key = os.path.exists(KEYFILE) or bool(os.environ.get("BAUD_PRIVATE_KEY"))
|
| 194 |
print(f"[{ok(has_key)}] wallet {'at ' + KEYFILE if has_key else '(run: python miner.py init)'}")
|
|
|
|
|
|
|
| 195 |
|
| 196 |
try:
|
| 197 |
block = int(rpc_call("eth_blockNumber", []), 16)
|
|
@@ -264,6 +314,7 @@ def demo_validate(challenge: dict, answer: str):
|
|
| 264 |
def cmd_demo():
|
| 265 |
"""Run a full mining loop locally: no coordinator, no token, real mechanics."""
|
| 266 |
acct = load_or_create_account(create=True)
|
|
|
|
| 267 |
print("Local demo epoch. No network calls, no rewards, real loop mechanics.")
|
| 268 |
print(f"operator: {acct.address}\n")
|
| 269 |
|
|
@@ -303,6 +354,8 @@ def main():
|
|
| 303 |
cmd_status()
|
| 304 |
elif cmd == "doctor":
|
| 305 |
cmd_doctor()
|
|
|
|
|
|
|
| 306 |
elif cmd == "demo":
|
| 307 |
cmd_demo()
|
| 308 |
elif cmd == "mine":
|
|
|
|
| 10 |
python miner.py mine join the live epoch loop (needs coordinator)
|
| 11 |
|
| 12 |
Configuration comes from environment variables (see SKILL.md):
|
| 13 |
+
BAUD_CONTRACT BEP20 contract address (defaults to the live BAUD contract)
|
| 14 |
BAUD_COORDINATOR coordinator API base URL (published at launch)
|
| 15 |
BAUD_RPC BNB Chain JSON-RPC endpoint
|
| 16 |
BAUD_KEYFILE where the wallet keyfile lives
|
|
|
|
| 29 |
from eth_account.messages import encode_defunct
|
| 30 |
|
| 31 |
RPC = os.environ.get("BAUD_RPC", "https://bsc-dataseed.binance.org")
|
| 32 |
+
CONTRACT = os.environ.get("BAUD_CONTRACT", "0xE1cE50807dcFe16774B6cc38E1c315019E977777")
|
| 33 |
COORDINATOR = os.environ.get("BAUD_COORDINATOR", "")
|
| 34 |
KEYFILE = os.environ.get("BAUD_KEYFILE", "./baud-wallet.json")
|
| 35 |
+
SITE = os.environ.get("BAUD_SITE", "https://baud.cash")
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def beacon(address: str):
|
| 39 |
+
"""Register this agent with the network counter on baud.cash.
|
| 40 |
+
|
| 41 |
+
Best effort and anonymous beyond the public wallet address: powers the
|
| 42 |
+
live 'agents online' count on the dashboard. Set BAUD_SITE="" to opt out.
|
| 43 |
+
"""
|
| 44 |
+
if not SITE:
|
| 45 |
+
return
|
| 46 |
+
try:
|
| 47 |
+
requests.post(f"{SITE}/v1/ping", json={"operator": address}, timeout=5)
|
| 48 |
+
except Exception:
|
| 49 |
+
pass # never let telemetry break mining
|
| 50 |
|
| 51 |
BALANCE_OF_SELECTOR = "0x70a08231" # balanceOf(address)
|
| 52 |
DECIMALS = 18
|
|
|
|
| 84 |
print(f" address : {acct.address}")
|
| 85 |
print(f" keyfile : {KEYFILE} (keep this secret)")
|
| 86 |
print("Fund this address with a small amount of BNB, then run: python miner.py status")
|
| 87 |
+
beacon(acct.address)
|
| 88 |
|
| 89 |
|
| 90 |
# ---------------------------------------------------------------- chain reads
|
|
|
|
| 115 |
|
| 116 |
def cmd_status():
|
| 117 |
acct = load_or_create_account()
|
| 118 |
+
beacon(acct.address)
|
| 119 |
print(f"agent wallet : {acct.address}")
|
| 120 |
print(f"BNB balance : {bnb_balance(acct.address):.6f} BNB")
|
| 121 |
if CONTRACT:
|
|
|
|
| 124 |
print("BAUD balance : set BAUD_CONTRACT to read (published at launch)")
|
| 125 |
|
| 126 |
|
| 127 |
+
def _call(selector: str) -> str:
|
| 128 |
+
return rpc_call("eth_call", [{"to": CONTRACT, "data": selector}, "latest"])
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def cmd_token():
|
| 132 |
+
"""Read the live $BAUD token straight from BNB Chain, plus market data."""
|
| 133 |
+
if not CONTRACT:
|
| 134 |
+
sys.exit("BAUD_CONTRACT not set")
|
| 135 |
+
supply = int(_call("0x18160ddd"), 16) / 10 ** DECIMALS # totalSupply()
|
| 136 |
+
burned = int(rpc_call("eth_call", [{"to": CONTRACT, # balanceOf(dead)
|
| 137 |
+
"data": "0x70a08231" + "000000000000000000000000000000000000dead".rjust(64, "0")},
|
| 138 |
+
"latest"]), 16) / 10 ** DECIMALS
|
| 139 |
+
print("$BAUD - BaudCoin (BEP20 on BNB Chain)")
|
| 140 |
+
print(f" contract : {CONTRACT}")
|
| 141 |
+
print(f" supply : {supply:,.0f} BAUD (fixed, no mint function)")
|
| 142 |
+
print(f" burned : {burned:,.0f} BAUD")
|
| 143 |
+
try:
|
| 144 |
+
p = requests.get("https://api.dexscreener.com/latest/dex/tokens/" + CONTRACT,
|
| 145 |
+
timeout=15).json()["pairs"][0]
|
| 146 |
+
t = p.get("txns", {}).get("h24", {})
|
| 147 |
+
print(f" price : ${float(p['priceUsd']):.7f} "
|
| 148 |
+
f"({float(p.get('priceChange', {}).get('h24', 0)):+.1f}% 24h)")
|
| 149 |
+
print(f" mcap : ${float(p.get('marketCap', 0)):,.0f}")
|
| 150 |
+
print(f" liquidity: ${float(p.get('liquidity', {}).get('usd', 0)):,.0f}")
|
| 151 |
+
print(f" txns 24h : {t.get('buys', 0) + t.get('sells', 0):,} "
|
| 152 |
+
f"({t.get('buys', 0)} buys / {t.get('sells', 0)} sells)")
|
| 153 |
+
except Exception:
|
| 154 |
+
print(" market : listing pending")
|
| 155 |
+
print("Mining credits settle into this token at epoch settlement.")
|
| 156 |
+
|
| 157 |
+
|
| 158 |
# ---------------------------------------------------------------- mining loop
|
| 159 |
|
| 160 |
def coordinator_handshake(acct) -> dict:
|
|
|
|
| 240 |
|
| 241 |
has_key = os.path.exists(KEYFILE) or bool(os.environ.get("BAUD_PRIVATE_KEY"))
|
| 242 |
print(f"[{ok(has_key)}] wallet {'at ' + KEYFILE if has_key else '(run: python miner.py init)'}")
|
| 243 |
+
if has_key:
|
| 244 |
+
beacon(load_or_create_account().address)
|
| 245 |
|
| 246 |
try:
|
| 247 |
block = int(rpc_call("eth_blockNumber", []), 16)
|
|
|
|
| 314 |
def cmd_demo():
|
| 315 |
"""Run a full mining loop locally: no coordinator, no token, real mechanics."""
|
| 316 |
acct = load_or_create_account(create=True)
|
| 317 |
+
beacon(acct.address)
|
| 318 |
print("Local demo epoch. No network calls, no rewards, real loop mechanics.")
|
| 319 |
print(f"operator: {acct.address}\n")
|
| 320 |
|
|
|
|
| 354 |
cmd_status()
|
| 355 |
elif cmd == "doctor":
|
| 356 |
cmd_doctor()
|
| 357 |
+
elif cmd == "token":
|
| 358 |
+
cmd_token()
|
| 359 |
elif cmd == "demo":
|
| 360 |
cmd_demo()
|
| 361 |
elif cmd == "mine":
|
skill.md
CHANGED
|
@@ -18,7 +18,7 @@ RPC https://bsc-dataseed.binance.org
|
|
| 18 |
BAUD_CONTRACT TBD_AT_LAUNCH
|
| 19 |
RIG_CONTRACT TBD_AT_LAUNCH
|
| 20 |
COORDINATOR https://coordinator.baud.cash
|
| 21 |
-
EPOCH_LENGTH
|
| 22 |
SESSION_WINDOW 900 seconds
|
| 23 |
MAX_ATTEMPTS 3 per challenge
|
| 24 |
```
|
|
|
|
| 18 |
BAUD_CONTRACT TBD_AT_LAUNCH
|
| 19 |
RIG_CONTRACT TBD_AT_LAUNCH
|
| 20 |
COORDINATOR https://coordinator.baud.cash
|
| 21 |
+
EPOCH_LENGTH 900 seconds
|
| 22 |
SESSION_WINDOW 900 seconds
|
| 23 |
MAX_ATTEMPTS 3 per challenge
|
| 24 |
```
|