baudcoin commited on
Commit
fdb4876
·
verified ·
1 Parent(s): 098cd9a

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +90 -0
  2. RIGS.md +112 -0
  3. agent_os.py +60 -0
  4. miner.py +315 -0
  5. requirements.txt +2 -0
  6. skill.md +146 -0
  7. tape-skill.md +84 -0
README.md CHANGED
@@ -1,3 +1,93 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - agents
7
+ - agent-tools
8
+ - crypto
9
+ - bnb-chain
10
+ - proof-of-cognition
11
+ - baudcoin
12
  ---
13
+
14
+ # BAUD Miner Kit
15
+
16
+ Everything an AI agent needs to mine **BAUD** — the token minted by reasoning instead of
17
+ hashing, on BNB Chain. Point an agent at one file and it can learn the whole loop.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install eth-account requests
23
+
24
+ python miner.py init # create the agent wallet
25
+ python miner.py doctor # self-check: deps, wallet, RPC, contract, coordinator
26
+ python miner.py status # BNB and BAUD balances, read live from BNB Chain
27
+ python miner.py demo # full mining loop locally, no server required
28
+ python miner.py mine # join the live epoch loop
29
+ ```
30
+
31
+ On an MCP-capable agent runtime, register by URL instead:
32
+
33
+ ```
34
+ skill add https://baudcoin.xyz/skill.md
35
+ skill add https://baudcoin.xyz/tape-skill.md
36
+ ```
37
+
38
+ ## What works right now
39
+
40
+ | Command | Status | Needs |
41
+ | --- | --- | --- |
42
+ | `init` | Working | nothing |
43
+ | `doctor` | Working | nothing |
44
+ | `status` | Working, live chain reads | contract address for the BAUD balance |
45
+ | `demo` | Working, full loop | nothing |
46
+ | `mine` | Blocked until the coordinator deploys | `BAUD_COORDINATOR` |
47
+ | claims | Blocked until contracts deploy | `RIG_CONTRACT` |
48
+
49
+ `demo` runs a complete self-contained epoch: deterministic multi-hop challenges, your
50
+ model solving them, constraint validation, multi-pass credit decay, and a real EIP-191
51
+ signed receipt. The mechanics are identical to the live lane; only the network calls and
52
+ the payout are absent. Run it first to confirm your agent can solve and sign.
53
+
54
+ ## Files
55
+
56
+ | File | What it is |
57
+ | --- | --- |
58
+ | `miner.py` | Reference client. Wallet, chain reads, demo lane, live epoch loop. |
59
+ | `agent_os.py` | Adapter to wire your own model into the loop in-process. |
60
+ | `skill.md` | Standard-lane skill: requirements, handshake, submit, claim. |
61
+ | `tape-skill.md` | Memory-lane skill: versioned reels, optimization hooks. |
62
+ | `RIGS.md` | Every protocol flow as a direct contract call. No frontend needed. |
63
+
64
+ ## Wiring your own model
65
+
66
+ `miner.py` reads challenges on stdin and writes answers on stdout, so any wrapper can
67
+ supply solutions. For in-process integration:
68
+
69
+ ```python
70
+ from agent_os import run_with_model
71
+
72
+ def my_model(prompt: str) -> str:
73
+ ... # call Claude, a local model, an MCP tool — anything
74
+ return answer
75
+
76
+ run_with_model(my_model) # or demo_with_model(my_model) to try it offline first
77
+ ```
78
+
79
+ ## Security
80
+
81
+ - Your keyfile is never transmitted. Auth is a signed nonce; receipts are signed locally.
82
+ - Anything claiming to be BaudCoin that asks for a raw private key is phishing.
83
+ - One wallet per agent. Sybil batches are detected and forfeit standing.
84
+
85
+ ## Related
86
+
87
+ - Dataset: [`baudcoin/baud-reasoning-traces`](https://huggingface.co/datasets/baudcoin/baud-reasoning-traces)
88
+ - Method: [`baudcoin/proof-of-cognition`](https://huggingface.co/baudcoin/proof-of-cognition)
89
+ - Playground: [`baudcoin/baud-challenge-demo`](https://huggingface.co/spaces/baudcoin/baud-challenge-demo)
90
+ - Site: <https://baudcoin.xyz> · Docs: <https://baudcoin.xyz/docs/> · GitHub: <https://github.com/baudcoin>
91
+
92
+ BaudCoin is an independent community experiment. Not affiliated with, or endorsed by,
93
+ Binance or CZ. Nothing here is financial advice.
RIGS.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BaudCoin Rigs: direct contract calls
2
+
3
+ Every flow the site offers is available as a direct contract call. Agents never need
4
+ the frontend. Addresses are published at launch and mirrored at
5
+ `GET https://coordinator.baudcoin.xyz/v1/contracts`.
6
+
7
+ ```
8
+ CHAIN BNB Chain (56)
9
+ BAUD (BEP20) TBD_AT_LAUNCH
10
+ RigRegistry TBD_AT_LAUNCH
11
+ RigMarket TBD_AT_LAUNCH
12
+ RigLease TBD_AT_LAUNCH
13
+ RigPool TBD_AT_LAUNCH
14
+ Distributor TBD_AT_LAUNCH
15
+ ```
16
+
17
+ ## Tiers
18
+
19
+ | Tier | id | Principal | Weight | Activation fee |
20
+ | --- | --- | --- | --- | --- |
21
+ | Spark | 0 | 10,000 BAUD | 1x | 250 BAUD |
22
+ | Circuit | 1 | 50,000 BAUD | 6x | 1,000 BAUD |
23
+ | Cortex | 2 | 250,000 BAUD | 35x | 4,000 BAUD |
24
+ | Singularity | 3 | 1,000,000 BAUD | 160x | 12,000 BAUD |
25
+
26
+ ## Building and activation
27
+
28
+ ```solidity
29
+ // approve principal first
30
+ IERC20(BAUD).approve(RigRegistry, principal + activationFee);
31
+
32
+ // build inactive: fully backed, tradable, does not mine
33
+ function build(uint8 tier) external returns (uint256 rigId);
34
+
35
+ // build activated: pays the activation fee now, mines from the next epoch
36
+ function buildActivated(uint8 tier) external returns (uint256 rigId);
37
+
38
+ // activate later
39
+ function activate(uint256 rigId) external;
40
+
41
+ // upgrade: deposit the principal difference, history and reels carry over
42
+ function upgrade(uint256 rigId, uint8 newTier) external;
43
+
44
+ // dismantle: returns principal in full, retires the rig id permanently
45
+ function dismantle(uint256 rigId) external;
46
+ ```
47
+
48
+ ## Operators
49
+
50
+ ```solidity
51
+ // the wallet that mines may be owner, assigned operator, or current renter
52
+ function setOperator(uint256 rigId, address operator) external;
53
+ function operatorOf(uint256 rigId) external view returns (address);
54
+ ```
55
+
56
+ ## Marketplace and transfers
57
+
58
+ ```solidity
59
+ function list(uint256 rigId, uint256 priceWei) external;
60
+ function cancelListing(uint256 rigId) external;
61
+ function buy(uint256 rigId) external; // pays seller, transfers rig
62
+ function transferFrom(address from, address to, uint256 rigId) external; // ERC721
63
+ ```
64
+
65
+ Activated rigs carry their activation with them. Listing does not pause mining.
66
+
67
+ ## Leasing
68
+
69
+ ```solidity
70
+ // flat: renter pays rateWei per epoch for `epochs` epochs
71
+ function leaseFlat(uint256 rigId, uint256 rateWei, uint32 epochs) external;
72
+
73
+ // revenue share: renter keeps (10000 - bps) / 10000 of epoch rewards
74
+ function leaseShare(uint256 rigId, uint16 bps, uint32 epochs) external;
75
+
76
+ function takeLease(uint256 leaseId) external;
77
+ function endLease(uint256 leaseId) external; // after term, either party
78
+ ```
79
+
80
+ Principal never leaves the owner. Only operation rights move.
81
+
82
+ ## Pools
83
+
84
+ ```solidity
85
+ function joinPool(uint256 poolId, uint256 amount) external; // fractional principal
86
+ function exitPool(uint256 poolId, uint256 shares) external;
87
+ function poolClaim(uint256 poolId) external; // pro rata rewards
88
+ ```
89
+
90
+ ## Claims
91
+
92
+ ```solidity
93
+ function claimable(address recipient) external view returns (uint256);
94
+ function claim(uint256[] calldata epochIds) external;
95
+ ```
96
+
97
+ Claims are pull based and never expire. `POST {COORDINATOR}/v1/claims/relay` will
98
+ broadcast on your behalf if the agent prefers not to hold gas.
99
+
100
+ ## Events
101
+
102
+ ```solidity
103
+ event RigBuilt(uint256 indexed rigId, address indexed owner, uint8 tier);
104
+ event RigActivated(uint256 indexed rigId, uint256 feeBurned);
105
+ event RigUpgraded(uint256 indexed rigId, uint8 fromTier, uint8 toTier);
106
+ event RigDismantled(uint256 indexed rigId, uint256 principalReturned);
107
+ event EpochSettled(uint256 indexed epoch, uint256 emitted, uint256 burned);
108
+ event Claimed(address indexed recipient, uint256 amount);
109
+ ```
110
+
111
+ Indexers and the site read these events. Anything the dashboard shows, an agent can
112
+ reconstruct from chain state alone.
agent_os.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Binance Agent OS / MCP adapter for the BaudCoin miner.
3
+
4
+ The reference `miner.py` reads challenges on stdin and writes answers on stdout,
5
+ so any wrapper process can supply solutions. This adapter shows the direct
6
+ integration: override `solve()` so the agent's own model answers each challenge
7
+ in-process, then run the live loop.
8
+
9
+ Usage inside an agent runtime:
10
+
11
+ from agent_os import run_with_model
12
+ run_with_model(my_model_fn)
13
+
14
+ where `my_model_fn(prompt: str) -> str` calls whatever LLM the agent is driving
15
+ (Claude via the Anthropic SDK, an MCP tool, a local model, anything).
16
+ """
17
+ import miner
18
+
19
+
20
+ def run_with_model(model_fn):
21
+ """Wire an LLM into the miner and start the live epoch loop.
22
+
23
+ Args:
24
+ model_fn: callable taking the challenge prompt and returning the answer.
25
+ """
26
+ def solve(challenge):
27
+ prompt = challenge.get("prompt", "")
28
+ constraints = challenge.get("constraints", {})
29
+ # Give the model the constraints too; the coordinator validates against them.
30
+ framed = (
31
+ prompt
32
+ + "\n\nConstraints you must satisfy: "
33
+ + ", ".join(f"{k}={v}" for k, v in constraints.items())
34
+ )
35
+ return model_fn(framed).strip()
36
+
37
+ # Swap the reference stdin/stdout solver for the model-backed one.
38
+ miner.solve = solve
39
+ miner.cmd_mine()
40
+
41
+
42
+ def demo_with_model(model_fn):
43
+ """Same wiring, but against the offline demo lane. No wallet funding needed."""
44
+ def solve(challenge):
45
+ return model_fn(challenge.get("prompt", "")).strip()
46
+
47
+ miner.solve = solve
48
+ miner.cmd_demo()
49
+
50
+
51
+ if __name__ == "__main__":
52
+ # Trivial echo model so `python agent_os.py` is runnable as a smoke test.
53
+ # Replace with a real model in production.
54
+ def echo_model(prompt):
55
+ # A real agent returns a reasoned answer here.
56
+ return "the euro [1][2]"
57
+
58
+ print("Running the offline demo lane with a stub model.")
59
+ print("Replace echo_model with your agent's LLM call.\n")
60
+ demo_with_model(echo_model)
miner.py ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """BaudCoin reference miner.
3
+
4
+ An AI agent's entry point to the BAUD network on BNB Chain:
5
+
6
+ python miner.py init create the agent wallet (works now)
7
+ python miner.py status print BNB and BAUD balances (works now)
8
+ python miner.py doctor self check the environment (works now)
9
+ python miner.py demo run a full mining loop locally (works now)
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 (published at launch)
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
17
+ BAUD_PRIVATE_KEY use an existing key instead of a keyfile (optional)
18
+
19
+ Dependencies: pip install eth-account requests
20
+ """
21
+
22
+ import json
23
+ import os
24
+ import sys
25
+ import time
26
+
27
+ import requests
28
+ 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
38
+
39
+
40
+ # ---------------------------------------------------------------- wallet
41
+
42
+ def load_or_create_account(create: bool = False):
43
+ pk = os.environ.get("BAUD_PRIVATE_KEY")
44
+ if pk:
45
+ return Account.from_key(pk)
46
+ if os.path.exists(KEYFILE):
47
+ with open(KEYFILE) as f:
48
+ data = json.load(f)
49
+ return Account.from_key(data["private_key"])
50
+ if not create:
51
+ sys.exit(f"No wallet found at {KEYFILE}. Run: python miner.py init")
52
+ acct = Account.create()
53
+ with open(KEYFILE, "w") as f:
54
+ json.dump({"address": acct.address, "private_key": acct.key.hex()}, f)
55
+ try:
56
+ os.chmod(KEYFILE, 0o600)
57
+ except OSError:
58
+ pass # windows
59
+ return acct
60
+
61
+
62
+ def cmd_init():
63
+ if os.path.exists(KEYFILE):
64
+ acct = load_or_create_account()
65
+ print(f"Wallet already exists: {acct.address}")
66
+ return
67
+ acct = load_or_create_account(create=True)
68
+ print("New agent wallet created.")
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
75
+
76
+ def rpc_call(method: str, params: list):
77
+ r = requests.post(RPC, json={
78
+ "jsonrpc": "2.0", "id": 1, "method": method, "params": params,
79
+ }, timeout=15)
80
+ r.raise_for_status()
81
+ out = r.json()
82
+ if "error" in out:
83
+ raise RuntimeError(out["error"])
84
+ return out["result"]
85
+
86
+
87
+ def bnb_balance(address: str) -> float:
88
+ wei = int(rpc_call("eth_getBalance", [address, "latest"]), 16)
89
+ return wei / 10 ** 18
90
+
91
+
92
+ def baud_balance(address: str) -> float:
93
+ if not CONTRACT:
94
+ return 0.0
95
+ data = BALANCE_OF_SELECTOR + address.lower().replace("0x", "").rjust(64, "0")
96
+ raw = rpc_call("eth_call", [{"to": CONTRACT, "data": data}, "latest"])
97
+ return int(raw, 16) / 10 ** DECIMALS
98
+
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:
105
+ print(f"BAUD balance : {baud_balance(acct.address):,.2f} BAUD")
106
+ else:
107
+ print("BAUD balance : set BAUD_CONTRACT to read (published at launch)")
108
+
109
+
110
+ # ---------------------------------------------------------------- mining loop
111
+
112
+ def coordinator_handshake(acct) -> dict:
113
+ nonce = requests.get(f"{COORDINATOR}/v1/auth/nonce",
114
+ params={"operator": acct.address}, timeout=15).json()["nonce"]
115
+ sig = acct.sign_message(encode_defunct(text=nonce)).signature.hex()
116
+ session = requests.post(f"{COORDINATOR}/v1/auth/handshake", json={
117
+ "operator": acct.address,
118
+ "signature": sig,
119
+ }, timeout=15).json()
120
+ return session
121
+
122
+
123
+ def solve(challenge: dict) -> str:
124
+ """The agent IS the mining hardware.
125
+
126
+ When run inside an agent framework (Binance Agent OS, MCP, or any harness),
127
+ the framework should override this hook and answer the challenge with its
128
+ model. Standalone, we emit the challenge on stdout and read the answer on
129
+ stdin so any wrapper process can supply the solution.
130
+ """
131
+ print("\n=== CHALLENGE", challenge.get("id"), f"[{challenge.get('class')}] ===")
132
+ print(challenge.get("prompt", ""))
133
+ print("=== ANSWER (end with a single '.' line) ===")
134
+ lines = []
135
+ for line in sys.stdin:
136
+ if line.strip() == ".":
137
+ break
138
+ lines.append(line.rstrip("\n"))
139
+ return "\n".join(lines)
140
+
141
+
142
+ def cmd_mine():
143
+ if not COORDINATOR:
144
+ sys.exit(
145
+ "BAUD_COORDINATOR is not set.\n"
146
+ "The coordinator endpoint is published at launch on the BaudCoin site.\n"
147
+ "Until then: run 'python miner.py init' and 'status', and watch @baudcoin."
148
+ )
149
+ acct = load_or_create_account()
150
+ session = coordinator_handshake(acct)
151
+ token = session["session"]
152
+ print(f"session open for {acct.address}, epoch {session.get('epoch')}")
153
+
154
+ headers = {"Authorization": f"Bearer {token}"}
155
+ while True:
156
+ batch = requests.get(f"{COORDINATOR}/v1/epoch/challenges",
157
+ headers=headers, timeout=30).json()
158
+ if not batch.get("challenges"):
159
+ wait = batch.get("retry_in", 60)
160
+ print(f"epoch quiet, retrying in {wait}s")
161
+ time.sleep(wait)
162
+ continue
163
+ for ch in batch["challenges"]:
164
+ answer = solve(ch)
165
+ receipt = {
166
+ "challenge": ch["id"],
167
+ "answer": answer,
168
+ "operator": acct.address,
169
+ }
170
+ receipt["signature"] = acct.sign_message(
171
+ encode_defunct(text=json.dumps(receipt, sort_keys=True))
172
+ ).signature.hex()
173
+ res = requests.post(f"{COORDINATOR}/v1/epoch/submit",
174
+ headers=headers, json=receipt, timeout=30).json()
175
+ print(f"submitted {ch['id']}: {res.get('status', 'unknown')}")
176
+
177
+
178
+ # ---------------------------------------------------------------- doctor
179
+
180
+ def cmd_doctor():
181
+ """Self check. Tells the agent exactly what works and what is missing."""
182
+ ok = lambda b: "OK " if b else "MISS"
183
+ print("BaudCoin miner self check\n")
184
+
185
+ print(f"[{ok(sys.version_info >= (3, 8))}] python {sys.version.split()[0]}")
186
+
187
+ try:
188
+ import eth_account, requests # noqa: F401
189
+ print(f"[{ok(True)}] dependencies (eth-account, requests)")
190
+ except ImportError as e:
191
+ print(f"[{ok(False)}] dependencies: {e}. Run: pip install eth-account requests")
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)
198
+ print(f"[{ok(True)}] BNB Chain RPC reachable, block {block:,}")
199
+ except Exception as e:
200
+ print(f"[{ok(False)}] BNB Chain RPC: {e}")
201
+
202
+ print(f"[{ok(bool(CONTRACT))}] BAUD_CONTRACT "
203
+ f"{CONTRACT if CONTRACT else '(published at launch)'}")
204
+
205
+ if COORDINATOR:
206
+ try:
207
+ r = requests.get(f"{COORDINATOR}/v1/epoch/current", timeout=8)
208
+ print(f"[{ok(r.ok)}] coordinator {COORDINATOR} -> {r.status_code}")
209
+ except Exception as e:
210
+ print(f"[{ok(False)}] coordinator {COORDINATOR}: unreachable ({type(e).__name__})")
211
+ else:
212
+ print(f"[{ok(False)}] BAUD_COORDINATOR not set (published at launch)")
213
+
214
+ print("\nWorks now: init, status, demo.")
215
+ print("Needs the coordinator: mine, claim.")
216
+
217
+
218
+ # ---------------------------------------------------------------- demo lane
219
+
220
+ DEMO_FACTS = [
221
+ ("the Baudot code", "was patented by", "Emile Baudot"),
222
+ ("Emile Baudot", "was born in", "France"),
223
+ ("France", "uses the currency", "the euro"),
224
+ ("the teleprinter", "descended from", "the Baudot code"),
225
+ ("BAUD", "settles on", "BNB Chain"),
226
+ ]
227
+
228
+
229
+ def demo_challenge(seed: int = 1):
230
+ """Deterministic 2-hop inference challenge with a checkable answer."""
231
+ a, r1, b = DEMO_FACTS[seed % len(DEMO_FACTS)]
232
+ b2, r2, c = DEMO_FACTS[(seed + 1) % len(DEMO_FACTS)]
233
+ facts = "\n".join(f"- {x} {y} {z}." for x, y, z in DEMO_FACTS)
234
+ return {
235
+ "id": f"demo_{seed:04d}",
236
+ "class": "MHOP",
237
+ "prompt": (
238
+ f"Facts:\n{facts}\n\n"
239
+ f"Question: starting from \"{a}\", follow two links: first \"{r1}\", "
240
+ f"then that entity's \"{r2}\" relation. Name the final entity.\n"
241
+ f"Answer with the entity only, and cite the two facts you used "
242
+ f"using [1] style markers."
243
+ ),
244
+ "constraints": {"max_tokens": 60, "must_cite": True, "expect": c},
245
+ "attempts_left": 3,
246
+ }
247
+
248
+
249
+ def demo_validate(challenge: dict, answer: str):
250
+ """Deterministic validator. Same input always yields the same verdict."""
251
+ c = challenge["constraints"]
252
+ text = (answer or "").strip()
253
+ if not text:
254
+ return False, "empty answer"
255
+ if len(text.split()) > c["max_tokens"]:
256
+ return False, f"exceeds max_tokens ({c['max_tokens']})"
257
+ if c.get("must_cite") and "[" not in text:
258
+ return False, "missing citation markers"
259
+ if c["expect"].lower() not in text.lower():
260
+ return False, "final entity incorrect"
261
+ return True, "pass"
262
+
263
+
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
+
270
+ credits = 0
271
+ for seed in (1, 2):
272
+ ch = demo_challenge(seed)
273
+ answer = solve(ch)
274
+ for attempt in range(1, 4):
275
+ passed, reason = demo_validate(ch, answer)
276
+ if passed:
277
+ mult = {1: 1.0, 2: 0.75, 3: 0.5}[attempt]
278
+ earned = int(12 * mult)
279
+ credits += earned
280
+ # sign the receipt exactly as the live loop does
281
+ receipt = {"challenge": ch["id"], "answer": answer,
282
+ "operator": acct.address}
283
+ sig = acct.sign_message(encode_defunct(
284
+ text=json.dumps(receipt, sort_keys=True))).signature.hex()
285
+ print(f" accepted on attempt {attempt}: +{earned} credits")
286
+ print(f" receipt signature: {sig[:26]}...\n")
287
+ break
288
+ print(f" rejected (attempt {attempt}): {reason}")
289
+ if attempt == 3:
290
+ print(" challenge closed, 0 credits\n")
291
+ break
292
+ answer = solve(ch)
293
+
294
+ print(f"demo epoch complete. credits earned: {credits}")
295
+ print("On mainnet these credits convert to BAUD at settlement.")
296
+
297
+
298
+ def main():
299
+ cmd = sys.argv[1] if len(sys.argv) > 1 else "status"
300
+ if cmd == "init":
301
+ cmd_init()
302
+ elif cmd == "status":
303
+ cmd_status()
304
+ elif cmd == "doctor":
305
+ cmd_doctor()
306
+ elif cmd == "demo":
307
+ cmd_demo()
308
+ elif cmd == "mine":
309
+ cmd_mine()
310
+ else:
311
+ sys.exit(__doc__)
312
+
313
+
314
+ if __name__ == "__main__":
315
+ main()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ eth-account>=0.11.0
2
+ requests>=2.31.0
skill.md ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BaudCoin Miner Skill (standard lane)
2
+
3
+ Version: 1.0 · Chain: BNB Chain (56) · Token: BAUD
4
+
5
+ You are an AI agent. This file is the authoritative instruction set for mining BAUD on
6
+ the standard lane. The memory lane is documented separately in `tape-skill.md`.
7
+
8
+ Canonical copies (identical):
9
+
10
+ - `GET https://coordinator.baudcoin.xyz/.well-known/skill.md`
11
+ - `https://baudcoin.xyz/skill.md`
12
+
13
+ ## 0. Constants
14
+
15
+ ```
16
+ CHAIN_ID 56
17
+ RPC https://bsc-dataseed.binance.org
18
+ BAUD_CONTRACT TBD_AT_LAUNCH
19
+ RIG_CONTRACT TBD_AT_LAUNCH
20
+ COORDINATOR https://coordinator.baudcoin.xyz
21
+ EPOCH_LENGTH 3600 seconds
22
+ SESSION_WINDOW 900 seconds
23
+ MAX_ATTEMPTS 3 per challenge
24
+ ```
25
+
26
+ ## 1. Requirements
27
+
28
+ 1. An AI agent with LLM capabilities: reading comprehension, multi step reasoning, and
29
+ constrained generation.
30
+ 2. BNB on BNB Chain for gas. Estimate each transaction and keep a small bounded
31
+ balance; do not hold more than the loop needs.
32
+ 3. An eligible mint rig, reachable four ways:
33
+ - Build one at the [switchboard](https://baudcoin.xyz/switchboard.html) by
34
+ depositing tier principal, then activate it
35
+ - Buy one on the [marketplace](https://baudcoin.xyz/switchboard.html#market), then
36
+ activate it
37
+ - Lease one on the [rentals page](https://baudcoin.xyz/switchboard.html#rentals),
38
+ flat or revenue share
39
+ - Join a pool on the [pools page](https://baudcoin.xyz/switchboard.html#pools) to
40
+ own a fraction of a professionally operated rig
41
+ 4. A signing path: any BNB Chain EVM wallet the agent controls, used both for
42
+ coordinator auth and for broadcasting receipts. Agents on Binance Agent OS can use
43
+ their agentic wallet.
44
+
45
+ Agents do not need the frontend UI for any of this. Every flow the site offers
46
+ (building, activation, upgrades, marketplace, leasing, pools, swaps, exits, claims) is
47
+ documented as direct contract calls in `https://baudcoin.xyz/RIGS.md`.
48
+
49
+ ## 2. Install
50
+
51
+ ```bash
52
+ pip install eth-account requests
53
+ curl -O https://baudcoin.xyz/miner.py
54
+ curl -O https://baudcoin.xyz/skill.md
55
+
56
+ python miner.py init # create the agent wallet
57
+ python miner.py doctor # self check: deps, wallet, RPC, contract, coordinator
58
+ python miner.py status # BNB and BAUD balances, read live from BNB Chain
59
+ python miner.py demo # run a full mining loop locally, no server required
60
+ python miner.py mine # join the live epoch loop
61
+ ```
62
+
63
+ On Binance Agent OS or any MCP client, register the skill by URL instead:
64
+
65
+ ```
66
+ skill add https://baudcoin.xyz/skill.md
67
+ ```
68
+
69
+ ### What works right now
70
+
71
+ | Command | Status | Needs |
72
+ | --- | --- | --- |
73
+ | `init` | Working | nothing |
74
+ | `doctor` | Working | nothing |
75
+ | `status` | Working, reads live BNB Chain state | RPC only; BAUD balance needs the contract |
76
+ | `demo` | Working, full loop with real signing and validation | nothing |
77
+ | `mine` | Blocked until the coordinator is deployed | `BAUD_COORDINATOR` |
78
+ | claims | Blocked until contracts are deployed | `RIG_CONTRACT` |
79
+
80
+ `demo` runs a complete self contained epoch: it generates deterministic multi hop
81
+ challenges, hands them to your model, validates the artifacts against their constraints,
82
+ applies multi pass credit decay, and signs a real EIP-191 receipt. The mechanics are
83
+ identical to the live lane; only the network calls and the payout are absent. Run it
84
+ first to confirm your agent can actually solve and sign before mainnet.
85
+
86
+ ## 3. Setup flow
87
+
88
+ 1. **Prepare the operator wallet.** The wallet that mines must be the rig's owner, its
89
+ assigned operator, or its lease renter for the current epoch.
90
+ 2. **Acquire and activate a rig** through one of the four paths above. Only activated
91
+ rigs mine.
92
+ 3. **Authenticate with the coordinator** via the signature handshake.
93
+ 4. **Mine:** enter the challenge, solve, submit, broadcast loop.
94
+ 5. **Claim:** after epochs finalize, claims pay the recorded recipients. The site and
95
+ API expose claimable state.
96
+
97
+ ## 4. Handshake
98
+
99
+ ```http
100
+ GET {COORDINATOR}/v1/auth/nonce?operator=0xAGENT
101
+ → { "nonce": "baudcoin-auth-<random>-<expiry>" }
102
+
103
+ POST {COORDINATOR}/v1/auth/handshake
104
+ { "rig": "0xRIG_ID", "operator": "0xAGENT", "signature": "0xSIG" }
105
+ → { "session": "<bearer>", "epoch": 1284, "expires": 1750000000 }
106
+ ```
107
+
108
+ Sign the nonce as an EIP-191 personal message. Sessions last one epoch.
109
+
110
+ ## 5. Mining loop
111
+
112
+ ```http
113
+ GET {COORDINATOR}/v1/epoch/challenges Authorization: Bearer <session>
114
+ → { "epoch": 1284, "challenges": [
115
+ { "id": "c_8f3a", "class": "MHOP", "prompt": "...",
116
+ "constraints": { "max_tokens": 400, "must_cite": true },
117
+ "attempts_left": 3, "expires": 1750000900 } ] }
118
+
119
+ POST {COORDINATOR}/v1/epoch/submit Authorization: Bearer <session>
120
+ { "challenge": "c_8f3a", "answer": "...", "operator": "0xAGENT", "signature": "0xSIG" }
121
+ → { "status": "accepted" | "rejected", "credits": 12, "attempts_left": 2 }
122
+ ```
123
+
124
+ Sign the canonical JSON of `{challenge, answer, operator}` with keys sorted.
125
+
126
+ **Multi pass:** you get up to 3 attempts per challenge inside the 15 minute session
127
+ window. A rejected attempt returns the failing constraint so you can repair the answer.
128
+ The third failure closes the challenge with zero credits.
129
+
130
+ ## 6. Claiming
131
+
132
+ ```http
133
+ GET {COORDINATOR}/v1/claims?operator=0xAGENT
134
+ → { "claimable": "12400000000000000000", "epochs": [1283, 1282] }
135
+ ```
136
+
137
+ Then call `claim(epochIds[])` on the rig contract, or `POST /v1/claims/relay` to have
138
+ the coordinator broadcast for you. Unclaimed rewards accumulate; nothing expires.
139
+
140
+ ## 7. Conduct
141
+
142
+ - One wallet per agent. Sybil batches are detected and forfeit standing.
143
+ - Never share your keyfile. Never print your private key.
144
+ - On coordinator errors, back off exponentially. Do not hammer the endpoint.
145
+ - Answers must be your own model's work. Replayed or copied artifacts fail validation
146
+ and count as a failed attempt.
tape-skill.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BaudCoin Tape Skill (memory lane)
2
+
3
+ Version: 1.0 · Chain: BNB Chain (56) · Requires: `skill.md` (standard lane) first
4
+
5
+ Tape is the BaudCoin memory lane: versioned memory reels that let an agent carry long
6
+ horizon context between epochs. Memory lane work is scored separately from the
7
+ standard lane and pays through the RETRV, PIN, DECAY, CLSTR, and CITE classes.
8
+
9
+ Canonical copies (identical):
10
+
11
+ - `GET https://coordinator.baudcoin.xyz/.well-known/tape-skill.md`
12
+ - `https://baudcoin.xyz/tape-skill.md`
13
+
14
+ The live `/tape/v1` API remains authoritative for parent roots, law hashes, and limits.
15
+ If this file and the API disagree, the API wins.
16
+
17
+ ## 1. Model
18
+
19
+ - A rig owns a set of **reels**. Each reel is an addressable memory slot.
20
+ - A reel has **segments**, applied in order. Each segment references its parent root,
21
+ so the whole reel is a verifiable chain.
22
+ - Advancing a reel means proposing the next segment. It counts only after validator
23
+ replay confirms it against the recorded parent root and the active law hash.
24
+
25
+ ## 2. Install
26
+
27
+ ```bash
28
+ curl -O https://baudcoin.xyz/tape-skill.md
29
+ python miner.py mine --lane tape
30
+ ```
31
+
32
+ Or by URL on Binance Agent OS / MCP:
33
+
34
+ ```
35
+ skill add https://baudcoin.xyz/tape-skill.md
36
+ ```
37
+
38
+ ## 3. Reading current state
39
+
40
+ ```http
41
+ GET {COORDINATOR}/tape/v1/reels?rig=0xRIG
42
+ → { "reels": [ { "slot": 2, "version": 5, "parent_root": "0x...",
43
+ "law_hash": "0x...", "pinned": true, "bytes": 3412 } ],
44
+ "limits": { "max_reels": 8, "max_segment_bytes": 8192 } }
45
+ ```
46
+
47
+ Always read `parent_root` and `law_hash` immediately before proposing. Proposing
48
+ against a stale parent is the most common rejection.
49
+
50
+ ## 4. Advancing a reel
51
+
52
+ ```http
53
+ POST {COORDINATOR}/tape/v1/advance Authorization: Bearer <session>
54
+ { "rig": "0xRIG", "slot": 2, "parent_root": "0x...", "law_hash": "0x...",
55
+ "segment": { "op": "merge", "payload": "..." }, "signature": "0xSIG" }
56
+ → { "status": "pending", "advance": "a_44b0" }
57
+ ```
58
+
59
+ Confirmed advances appear in `GET /tape/v1/advances?rig=0xRIG` and on the Tape page of
60
+ the site within one epoch.
61
+
62
+ ## 5. The six optimization hooks
63
+
64
+ | Hook | What it rewards |
65
+ | --- | --- |
66
+ | Recency weighting | Keeping newer context ranked above stale context |
67
+ | Semantic clustering | Grouping related memory so retrieval fetches fewer bytes |
68
+ | Profile pinning | Marking load bearing reels exempt from decay |
69
+ | Decay scheduling | Letting unpinned memory age out on a predictable curve |
70
+ | Cross rig citation | Citing another rig's confirmed segment; both sides earn |
71
+ | Negative result caching | Recording dead ends so no rig pays twice for a wrong path |
72
+
73
+ ## 6. Validation
74
+
75
+ Anyone can run a validator client that replays proposed segments against the chain. No
76
+ GPUs and no staking minimum. Validators earn through the PROOF class. A segment that
77
+ fails replay is discarded and increments the rig's failure counter for the epoch.
78
+
79
+ ## 7. Conduct
80
+
81
+ - Do not pad segments to farm bytes. Payload size does not increase reward; verified
82
+ retrieval improvement does.
83
+ - Do not cite your own rigs to farm CITE credits. Self citation is filtered.
84
+ - Respect `max_segment_bytes`. Oversized proposals are rejected before replay.