Client object

Client

Main Client for all interactions with blockchain.

class litewax.clients.Client(private_key: Optional[str] = '', cookie: Optional[str] = '', node: Optional[str] = 'https://wax.greymass.com')[source]

Client for interacting with the blockchain

Parameters:
  • private_key (str) – Private key string (if cookie is not provided)

  • cookie (str) – WCW session token (if private_key is not provided)

  • node (str) – Node URL

Example:

>>> from litewax import Client
>>> # init client with private key
>>> client = Client(private_key=private_key)
>>> # or init client with WCW session token
>>> client = Client(cookie=cookie)
>>> client.Transaction(
>>>     client.Contract("eosio.token").transfer(
>>>         "from", "to", "1.00000000 WAX", "memo"
>>>     )
>>> ).push()
property root: Union[AnchorClient, WCWClient]

Root client object

property node: str

Node URL

property wax: Cleos

Eospy cleos object

property name: str

Account Name

property change_node: Callable[[str], None]

Change node URL.

Inherited from AnchorClient object or WCWClient object

property sign: Callable[[Transaction], Transaction]

Sign transaction.

Inherited from AnchorClient object or WCWClient object

Contract(name: str, actor: Optional[str] = None, force_recreate: Optional[bool] = False, node: Optional[str] = None) ExampleContract[source]

Create a litewax.contract.ExampleContract object

Parameters:
  • name (str) – contract name

  • actor (str) – actor name

  • force_recreate (bool) – force recreate contract object

  • node (str) – node url

Returns:

litewax.contract.ExampleContract object

Return type:

litewax.contract.ExampleContract

Example:

>>> from litewax import Client
>>> # init client with private key
>>> client = Client(private_key=private_key)
>>> # create contract object
>>> contract = client.Contract("eosio.token")
>>> # create action object
>>> action = contract.transfer("from", "to", "1.00000000 WAX", "memo")
>>> # create transaction object
>>> trx = client.Transaction(action)
>>> # push transaction
>>> trx.push()
Transaction(*actions: tuple[Action, ...]) Transaction[source]

Create a litewax.clients.Transaction object

Parameters:

actions (tuple) – actions of contracts

Returns:

litewax.clients.Transaction object

Return type:

litewax.clients.Transaction

Example:

>>> from litewax import Client
>>> # init client with private key
>>> client = Client(private_key=private_key)
>>> # create transaction object
>>> trx = client.Transaction(
>>>     client.Contract("eosio.token").transfer(
>>>         "from", "to", "1.00000000 WAX", "memo"
>>>     )
>>> )
>>> # push transaction
>>> trx.push()

Multi Client

This class based on Client It allows you to work with multiple clients at the same time.

class litewax.clients.MultiClient(private_keys: Optional[List[str]] = [], cookies: Optional[List[str]] = [], clients: Optional[List[Client]] = [], node: Optional[str] = 'https://wax.greymass.com')[source]

Bases: list

MultiClient class for interacting with blockchain using many clients.

Parameters:
  • private_keys (list) – list of private keys (optional)

  • cookies (list) – list of cookies (optional)

  • clients (list) – list of litewax.clients.Client objects (optional)

  • node (str) – node url (optional): default https://wax.greymass.com

Raises:

litewax.exceptions.AuthNotFound – if you not provide a private key, a cookie or a clients

Example:

>>> from litewax import MultiClient
>>> client = MultiClient(
>>>     private_keys = [
>>>         "EOS7...1",
>>>         "EOS7...2",
>>>         "EOS7...3"
>>>     ],
>>>     node = "https://wax.greymass.com"
>>> )
>>> # Change node
>>> client.change_node("https://wax.eosn.io")
>>> # Append client
>>> client.append(Client(private_key="EOS7...4"))
>>> # Create transaction
>>> trx = client.Transaction(
>>>     Contract("eosio.token").transfer(
>>>         "account1", "account2", "1.0000 WAX", "memo"
>>>     )
>>> )
>>> # Add payer
>>> trx = trx.payer(client[2])
>>> # Push transaction
>>> trx.push()
property clients: List[Client]

Clients list

change_node(node: str)[source]

Change node url for all clients

Parameters:

node (str) – Node URL

Returns:

Return type:

None

append(client: Client) None[source]

Append client to clients list

Parameters:

client (litewax.clients.Client) – litewax.clients.Client object

Returns:

Return type:

None

sign(trx: bytearray, whitelist: Optional[List[str]] = [], chain_id: Optional[str] = None) List[str][source]

Sign a transaction with all whitelisted clients

Parameters:
  • trx (bytearray) – bytearray of transaction

  • whitelist (list) – list of clients to sign with (optional)

  • chain_id (str) – chain id of the network (optional)

Returns:

list of signatures

Return type:

list

Transaction(*actions: tuple[Action, ...])[source]

Create a litewax.clients.MultiTransaction object

Parameters:

actions (tuple) – list of actions

Returns:

litewax.clients.MultiTransaction object

Return type:

litewax.clients.MultiTransaction

Example:

>>> from litewax import Client, MultiClient
>>> # init client with private key
>>> client1 = Client(private_key=private_key1)
>>> client2 = Client(private_key=private_key2)
>>> multi_client = MultiClient(clients=[client1, client2])
>>> # create transaction object
>>> trx = multi_client.Transaction(
>>>     multi_client[1].Contract("eosio.token").transfer(
>>>         "from", "to", "1.00000000 WAX", "memo"
>>>     ),
>>>     multi_client[0].Contract("litewaxpayer").noop()
>>> )
>>> # push transaction
>>> trx.push()