Strategy API

For more info see Strategies In-Depth.

pab.strategy.import_strategies(root: pathlib.Path)

Imports strategies module from root directory.

class pab.strategy.BaseStrategy(blockchain: pab.blockchain.Blockchain, name: str)

Abstract Base Class for custom strategies.

blockchain: pab.blockchain.Blockchain

Current blockchain connection.

property accounts: Dict[int, 'LocalAccount']

Returns available accounts in current blockchain. You can access specific accounts with numeric indexes

property contracts: ContractManager

Returns a pab.contract.ContractManager. You can use self.contracts.get(name) to retrieve a contract by name.

abstract run()

Strategy entrypoint. Must be defined by all childs.

transact(account: LocalAccount, func: callable, args: tuple) TxReceipt

Makes a transaction on the current blockchain.

exception pab.strategy.PABError

Base class for errors while running tasks. Unhandleded PABErrors will prevent further excecutions of a strategy.

exception pab.strategy.RescheduleError

Strategies can raise this exception to tell PAB to reschedule them in known scenarios.

exception pab.strategy.SpecificTimeRescheduleError(message: str, next_at: Optional[int] = None)

Same as RescheduleError but at a specific time passed as a timestamp.