Pay CPU

pay_for_cpu_multiclient.py
 1from litewax import MultiClient, Contract
 2
 3# Create a client with a private keys
 4client = MultiClient(private_keys=["5K1...", "5K2...", "5K3..."])
 5
 6# Create the transaction
 7trx = client.Transaction(
 8    
 9    # Use a some contract action 1 
10    Contract("eosio.token", client[0]).transfer(
11        _from=client[0].name,
12        to=client[1].name,
13        quantity="1.00000000 WAX",
14        memo="Test send"
15    ),
16
17    # Use a some contract action 2
18    Contract("eosio.token", client[1]).transfer(
19        _from=client[1].name,
20        to=client[0].name,
21        quantity="1.00000000 WAX",
22        memo="Test send"
23    ),
24
25    # Sign last empty action for pay CPU. client[2] will pay for all transcation CPU
26    Contract("res.pink", client[2]).noop()
27)
28
29# Push the transaction
30r = trx.push()
31
32print(r)
33# {'transaction_id': '928802d253bffc29d6178e634052ec5f044b2fcce0c4c8bc5b44d978e22ec5d4', ...}