-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy path3_ValidatorAccount.py
More file actions
34 lines (24 loc) · 929 Bytes
/
3_ValidatorAccount.py
File metadata and controls
34 lines (24 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import asyncio
import json
import os
import dotenv
from pyinjective import PrivateKey
from pyinjective.async_client import AsyncClient
from pyinjective.core.network import Network
async def main() -> None:
dotenv.load_dotenv()
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
# select network: local, testnet, mainnet
network = Network.testnet()
# initialize grpc client
client = AsyncClient(network)
# load account
priv_key = PrivateKey.from_hex(configured_private_key)
pub_key = priv_key.to_public_key()
address = pub_key.to_address()
await client.fetch_account(address.to_acc_bech32())
cons_address = "injvalcons1h5u937etuat5hnr2s34yaaalfpkkscl5ndadqm"
result = await client.fetch_evm_validator_account(cons_address=cons_address)
print(json.dumps(result, indent=2))
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())