add ability to pull data from historical blocks
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
2b55ab4935
commit
36bebfcd84
@ -18,13 +18,14 @@ 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
|
||||||
usage: finder.py [-h] --rpc RPC [--bonus BONUS] [--delay DELAY]
|
usage: finder.py [-h] --rpc RPC [--block BLOCK] [--bonus BONUS] [--delay DELAY]
|
||||||
|
|
||||||
EVM NFT Snapshot Collector for Ghostchain Preclaims
|
EVM NFT Snapshot Collector for Ghostchain Preclaims
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--rpc RPC EVM JSON-RPC Node URL
|
--rpc RPC EVM JSON-RPC Node URL
|
||||||
|
--block BLOCK Target block number or 'latest' (default: latest)
|
||||||
--bonus BONUS Additional JML ownership amounton top of the collateral (default: 6.9 CSPR)
|
--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)
|
--delay DELAY Delay between RPC requests in seconds (default: 0.3)
|
||||||
```
|
```
|
||||||
|
|||||||
12
finder.py
12
finder.py
@ -12,7 +12,8 @@ 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("--block", default="latest", help="Target block number or 'latest' (default: latest)")
|
||||||
|
parser.add_argument("--bonus", type=int, 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()
|
||||||
|
|
||||||
@ -75,8 +76,11 @@ def main():
|
|||||||
chain_id = w3.eth.chain_id
|
chain_id = w3.eth.chain_id
|
||||||
print(f"[+] Successfully connected to [{chain_id}] over {args.rpc}.")
|
print(f"[+] Successfully connected to [{chain_id}] over {args.rpc}.")
|
||||||
|
|
||||||
|
target_block = int(args.block) if args.block.isdigit() else args.block
|
||||||
|
print(f"[+] Snapshot target block: {target_block}")
|
||||||
|
|
||||||
contract = get_contract_instance(w3)
|
contract = get_contract_instance(w3)
|
||||||
total_supply = contract.functions.totalSupply().call()
|
total_supply = contract.functions.totalSupply().call(block_identifier=target_block)
|
||||||
print(f"[+] Current totalSupply: {total_supply}")
|
print(f"[+] Current totalSupply: {total_supply}")
|
||||||
time.sleep(args.delay)
|
time.sleep(args.delay)
|
||||||
|
|
||||||
@ -93,9 +97,9 @@ def main():
|
|||||||
current_index = len(snapshot)
|
current_index = len(snapshot)
|
||||||
for token_id in tqdm(range(start_token_id, total_supply), desc=f"Scanning {chain_id}"):
|
for token_id in tqdm(range(start_token_id, total_supply), desc=f"Scanning {chain_id}"):
|
||||||
try:
|
try:
|
||||||
owner = contract.functions.ownerOf(token_id).call()
|
owner = contract.functions.ownerOf(token_id).call(block_identifier=target_block)
|
||||||
time.sleep(args.delay)
|
time.sleep(args.delay)
|
||||||
shares = contract.functions.collateralBalances(token_id, GMV_ADDRESS).call()
|
shares = contract.functions.collateralBalances(token_id, GMV_ADDRESS).call(block_identifier=target_block)
|
||||||
time.sleep(args.delay)
|
time.sleep(args.delay)
|
||||||
|
|
||||||
snapshot.append({
|
snapshot.append({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user