File size: 1,656 Bytes
160aacb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 json
import os
from web3 import Web3
from config import AppConfig

# --- 1. SETUP ---
# Connect to Pure Chain using your config
w3 = Web3(Web3.HTTPProvider(AppConfig.PURECHAIN_RPC_URL))
account = w3.eth.account.from_key(AppConfig.PRIVATE_KEY)

print(f"🔌 Connected to: {AppConfig.PURECHAIN_RPC_URL}")
print(f"👤 Deploying as: {account.address}")

# --- 2. DYNAMIC COMPILATION ---
print("⚙️ Dynamically compiling contract...")
from src.dynamic_compiler import get_contract_interface
abi, bytecode = get_contract_interface()

# --- 3. BUILD TRANSACTION ---
# Prepare the contract object
Contract = w3.eth.contract(abi=abi, bytecode=bytecode)

# Force a LEGACY transaction (Type 0/1) by manually setting gasPrice
# and avoiding maxFeePerGas/maxPriorityFeePerGas
print("🛠 Building Legacy Transaction...")
tx = Contract.constructor().build_transaction({
    'from': account.address,
    'nonce': w3.eth.get_transaction_count(account.address),
    'gas': 6000000,
    'gasPrice': 0,  # <--- This forces Legacy Mode AND 0 cost for PoA!
    'chainId': 900520900520
})

# --- 4. SIGN & SEND ---
print("✍️ Signing...")
signed_tx = w3.eth.account.sign_transaction(tx, AppConfig.PRIVATE_KEY)

print("🚀 Sending to Pure Chain...")
tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
print(f"✅ Transaction Sent! Hash: {w3.to_hex(tx_hash)}")

# --- 5. WAIT FOR RECEIPT ---
print("⏳ Waiting for confirmation...")
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)

print("-" * 30)
print(f"🎉 CONTRACT DEPLOYED AT: {tx_receipt.contractAddress}")
print("-" * 30)
print("👉 Copy this address and put it in your config.py!")