-
Notifications
You must be signed in to change notification settings - Fork 0
/
declare_v1.py
49 lines (38 loc) · 1.4 KB
/
declare_v1.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import toml
import logging
from asyncio import run
from pathlib import Path
from starknet_py.net.signer.stark_curve_signer import KeyPair
from starknet_py.net.full_node_client import FullNodeClient
from starknet_py.net.models.chains import StarknetChainId
from starknet_py.net.account.account import Account
# Set up logging
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
with open("config.toml", "r") as config_file:
config = toml.load(config_file)
# Accessing variables
ADDRESS = config.get("ADDRESS")
PRIV_KEY = config.get("PRIV_KEY")
NODE_URL = config.get("NODE_URL")
async def main():
key_pair = KeyPair.from_private_key(PRIV_KEY)
account = Account(
address=ADDRESS,
client=FullNodeClient(node_url=NODE_URL),
chain=StarknetChainId.MAINNET,
key_pair=key_pair,
)
logger.info("ℹ️ Using account %s as deployer", hex(account.address))
contract_file = Path("contracts/main.json").read_text()
declare_v1_tx = await account.sign_declare_transaction(
compiled_contract=contract_file,
max_fee=int(1e17),
)
resp = await account.client.declare(transaction=declare_v1_tx)
logger.info(f"ℹ️ tx hash: {hex(resp.transaction_hash)}")
await account.client.wait_for_tx(resp.transaction_hash)
logger.info(f"✅ class hash: {hex(resp.class_hash)}")
if __name__ == "__main__":
run(main())