Compare commits

...

2 Commits

Author SHA1 Message Date
16006babb7
use prefixes for the merkle tree
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2026-09-08 22:08:12 +03:00
33161daa00
additional bonus during data collection
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2026-09-03 12:12:43 +03:00
4 changed files with 25 additions and 12 deletions

2
.gitignore vendored
View File

@ -96,6 +96,8 @@ Desktop.ini
*.temp *.temp
# Project specific (for your snapshot collector) # Project specific (for your snapshot collector)
preclaims/*json
!preclaims/.gitkeep
snapshots/*.json snapshots/*.json
!snapshots/.gitkeep # Optional: keep the directory but not the files !snapshots/.gitkeep # Optional: keep the directory but not the files

View File

@ -18,13 +18,15 @@ pip install web3 tqdm
The Ghost Preclaim Snapshot Tool provides a straightforward command-line interface for collecting NFT snapshot data across multiple blockchain networks. Before running the tool, ensure you have properly configured your environment with the necessary RPC endpoints and network access credentials. The Ghost Preclaim Snapshot Tool provides a straightforward command-line interface for collecting NFT snapshot data across multiple blockchain networks. Before running the tool, ensure you have properly configured your environment with the necessary RPC endpoints and network access credentials.
```bash ```bash
python finder.py --rpc <RPC_URL> [--delay 0.3] usage: finder.py [-h] --rpc RPC [--bonus BONUS] [--delay DELAY]
```
Parameters: EVM NFT Snapshot Collector for Ghostchain Preclaims
```bash
--rpc: EVM JSON-RPC endpoint URL options:
--delay: (Optional) Delay between RPC requests in seconds (default: 0.3) -h, --help show this help message and exit
--rpc RPC EVM JSON-RPC Node URL
--bonus BONUS Additional JML ownership amounton top of the collateral (default: 6.9 CSPR)
--delay DELAY Delay between RPC requests in seconds (default: 0.3)
``` ```
Example: Example:
@ -38,13 +40,20 @@ python finder.py --rpc https://sepolia.infura.io/v3/YOUR_KEY
The Merkle proof generation module transforms raw snapshot data into cryptographically verifiable proofs that enable efficient and secure preclaim verification on the Ghostchain governance platform. This critical component ensures that only legitimate NFT holders can participate in governance decisions and claim their allocations. The Merkle proof generation module transforms raw snapshot data into cryptographically verifiable proofs that enable efficient and secure preclaim verification on the Ghostchain governance platform. This critical component ensures that only legitimate NFT holders can participate in governance decisions and claim their allocations.
```bash ```bash
python forester.py --chain <CHAIN_NAME> usage: forester.py [-h] --network-id NETWORK_ID
Dynamic Merkle Tree for Ghost Preclaims
options:
-h, --help show this help message and exit
--network-id NETWORK_ID
EVM numeric Network ID to mix into preimage (e.g., 11155111)
``` ```
Example: Example:
```bash ```bash
python forester.py --chain 11155111 python forester.py --network-id 11155111
``` ```
Output: Output:

View File

@ -12,6 +12,7 @@ GMV_ADDRESS = "0x7EF911f8ef130F73D166468c0068753932357B17"
def parse_arguments(): def parse_arguments():
parser = argparse.ArgumentParser(description="EVM NFT Snapshot Collector for Ghostchain Preclaims") parser = argparse.ArgumentParser(description="EVM NFT Snapshot Collector for Ghostchain Preclaims")
parser.add_argument("--rpc", required=True, help="EVM JSON-RPC Node URL") parser.add_argument("--rpc", required=True, help="EVM JSON-RPC Node URL")
parser.add_argument("--bonus", default=6900000000000000000, help="Additional JML ownership amounton top of the collateral (default: 6.9 CSPR)")
parser.add_argument("--delay", type=float, default=0.3, help="Delay between RPC requests in seconds (default: 0.3)") parser.add_argument("--delay", type=float, default=0.3, help="Delay between RPC requests in seconds (default: 0.3)")
return parser.parse_args() return parser.parse_args()
@ -101,7 +102,7 @@ def main():
"index": current_index, "index": current_index,
"token_id": token_id, "token_id": token_id,
"address": owner, "address": owner,
"shares": shares "shares": shares + args.bonus
}) })
current_index += 1 current_index += 1

View File

@ -17,7 +17,8 @@ def parse_arguments():
def keccak256(data: bytes) -> bytes: def keccak256(data: bytes) -> bytes:
return keccak(data) return keccak(data)
EMPTY_HASH = keccak256(b'') # prefix + empty bytes
EMPTY_HASH = keccak256(b'\x00' + b'\x00' * 32)
def next_power_of_two(n: int) -> int: def next_power_of_two(n: int) -> int:
if n <= 1: if n <= 1:
@ -47,7 +48,7 @@ def generate_tree(raw_values, network_id):
for item in raw_values: for item in raw_values:
idx = item['index'] idx = item['index']
preimage = generate_preimage(item['token_id'], item['address'], item['shares'], network_id) preimage = generate_preimage(item['token_id'], item['address'], item['shares'], network_id)
merkle_tree[idx] = keccak256(preimage) merkle_tree[idx] = keccak256(b'\x00' + preimage)
layer_start = 0 layer_start = 0
current_layer_len = padded_leaves current_layer_len = padded_leaves
@ -59,7 +60,7 @@ def generate_tree(raw_values, network_id):
left_bytes = merkle_tree[layer_index] left_bytes = merkle_tree[layer_index]
right_bytes = merkle_tree[layer_index | 1] right_bytes = merkle_tree[layer_index | 1]
combined = left_bytes + right_bytes combined = b'\x01' + left_bytes + right_bytes
merkle_tree[write_ptr] = keccak256(combined) merkle_tree[write_ptr] = keccak256(combined)
write_ptr += 1 write_ptr += 1