45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import sys
|
|
|
|
from chainlib.eth.constant import ZERO_ADDRESS
|
|
from chainlib.eth.gas import DefaultGasOracle
|
|
from chainlib.eth.nonce import DefaultNonceOracle
|
|
from chainlib.eth.tx import TxFactory
|
|
from chainlib.eth.connection import HTTPConnection
|
|
from chainlib.eth.hash import keccak256_string_to_hex
|
|
from chainlib.eth.rpc import jsonrpc_template
|
|
from chainlib.eth.error import EthException
|
|
import eth_abi
|
|
from hexathon import (
|
|
strip_0x,
|
|
add_0x,
|
|
)
|
|
|
|
i = 0
|
|
while True:
|
|
conn = HTTPConnection('http://localhost:63545')
|
|
gas_oracle = DefaultGasOracle(conn)
|
|
nonce_oracle = DefaultNonceOracle(ZERO_ADDRESS, conn)
|
|
|
|
# Get Token registry address
|
|
txf = TxFactory(signer=None, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=8996)
|
|
tx = txf.template(ZERO_ADDRESS, sys.argv[1])
|
|
identifiers_method = keccak256_string_to_hex('identifiers(uint256)')[:8]
|
|
data = add_0x(identifiers_method)
|
|
data += eth_abi.encode_single('uint256', i).hex()
|
|
txf.set_code(tx, data)
|
|
|
|
o = jsonrpc_template()
|
|
o['method'] = 'eth_call'
|
|
tx = txf.normalize(tx)
|
|
o['params'].append(tx)
|
|
o['params'].append('latest')
|
|
try:
|
|
r = conn.do(o)
|
|
except EthException:
|
|
break
|
|
id_bytes = bytes.fromhex(strip_0x(r))
|
|
id_str = id_bytes[:id_bytes.find(b'\x00')]
|
|
print(id_str.decode('utf-8̈́'))
|
|
i += 1
|
|
|