> For the complete documentation index, see [llms.txt](https://fortress-labs.gitbook.io/snakepath/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fortress-labs.gitbook.io/snakepath/relayer/relayer-autogenerated-python-documentation.md).

# Relayer Autogenerated Python Documentation

See the full Github repository for more details. These docs are autogenerated with Sphinx.

## Submodules[¶](broken://pages/rvFlthyVgbirkFr3ISub)

### TNLS-Relayers.base\_interface module[¶](broken://pages/rvFlthyVgbirkFr3ISub)

*class* base\_interface.BaseChainInterface[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Bases: `ABC`

Base class for all chain interfaces Governs transaction retrieval and creation

*abstract* get\_last\_block()[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Retrieves the current block height of the chain

*abstract* get\_transactions(*address*, *height=None*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Retrieves all transactions from the chain that fit interface-dependent filters

*abstract* sign\_and\_send\_transaction(*tx*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Given a raw transaction, signs it and sends it to the chain

Parameters:

**tx** – the raw transaction to be sent to the chain

*class* base\_interface.BaseContractInterface¶

Bases: `ABC`

Base class for all contract interfaces Governs contract interaction, execution, and event parsing.

address *= None*[¶](broken://pages/rvFlthyVgbirkFr3ISub)*abstract* call\_function(*function\_name*, *\*args*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Given a function in a contract, and the arguments to that function, calls it on chain

Parameters:

* **function\_name** – the name of the contract function to call
* \***args** – the (potentially many) arguments to pass to that function

*abstract* parse\_event\_from\_txn(*event\_name*, *txn*) → List\[Task]¶

Given a transaction, outputs all the events of a particular name that were emitted in that transaction

Parameters:

* **event\_name** – the event to look for
* **txn** – the transaction to parse

Returns: a list of Tasks corresponding to the events

*class* base\_interface.Task(*task\_dict*)¶

Bases: `object`

Task class representing an interchain message&#x20;

task\_destination\_network is the network where the message should be routed.

base\_interface.to\_dict(*dict\_to\_parse*)¶

deeply converts an attribute dictionary to a json serializable dict&#x20;

sourced from SO on attribute dictionaries:

Parameters:

**dict\_to\_parse** – the dict to parse

Returns: a serializable dict

base\_interface.translate\_dict(*dict\_to\_translate*, *translation\_mechanism*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Translates a dictionary from one format to another (for interchain translation)

Parameters:

* **dict\_to\_translate** – the dictionary to translate
* **translation\_mechanism** – the mechanism to use for translation

Returns: the translated dictionary

### TNLS-Relayers.eth\_interface module[¶](broken://pages/rvFlthyVgbirkFr3ISub)

*class* eth\_interface.EthContract(*interface*, *address*, *abi*, *\*\*\_kwargs*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Bases: `BaseContractInterface`

Implementation of BaseContractInterface for eth.

call\_function(*function\_name*, *\*args*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

See base\_interface.py for documentation

get\_function(*function\_name*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Gets a particular function from the contract.

Parameters:

**function\_name** – The name of the function to get.

parse\_event\_from\_txn(*event\_name*, *txn*) → List\[[Task](broken://pages/rvFlthyVgbirkFr3ISub)][¶](broken://pages/rvFlthyVgbirkFr3ISub)

See base\_interface.py for documentation

*class* eth\_interface.EthInterface(*private\_key=''*, *address=''*, *provider=None*, *\*\*\_kwargs*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Bases: `BaseChainInterface`

Implementaion of BaseChainInterface for eth.

create\_transaction(*contract\_function*, *\*args*, *\*\*kwargs*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

See base\_interface.py for documentation

get\_last\_block()[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Gets the number of the most recent block

get\_last\_txs(*block\_number=None*, *address=None*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Gets the transactions from a particular block for a particular address.

Parameters:

* **block\_number** – Which block to get
* **address** – Which address to get transactions for

Returns: a list of transaction receipts

get\_transactions(*address*, *height=None*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

See base\_interface.py for documentation

sign\_and\_send\_transaction(*tx*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

See base\_interface.py for documentation

### TNLS-Relayers.relayer module[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Overall execution:

poller:

every N seconds: poll both sides for gateway transactions parse transactions into list of objects save each object in task list spin up thread to handle routing each object to the right location

Individual thread: for each object: get destination network verify signature? stringify object as json send json string to destination network

*class* relayer.Relayer(*dict\_of\_names\_to\_interfaces: Dict\[str, Tuple\[BaseChainInterface, BaseContractInterface, str, str]]*, *num\_loops=None*)¶

Bases: `object`

poll\_for\_transactions()¶

Polls for transactions on all interfaces Updates task list with found events

route\_transaction(*task: Task*)¶

Given a Task, routes it where it’s supposed to go

> task: the Task to be routed

run()¶

Runs the central relayer event loop: poll for transactions, log them, handle transactions sleep

task\_list\_handle()¶

Spins up threads to handle each task in the task list

### TNLS-Relayers.scrt\_interface module[¶](broken://pages/rvFlthyVgbirkFr3ISub)

*class* scrt\_interface.SCRTContract(*interface*, *address*, *abi*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Bases: `BaseContractInterface`

Implements the BaseContractInterface standard for the Secret Network

call\_function(*function\_name*, *\*args*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Calls the given function with the given args

Parameters:

* **function\_name** – which function to call
* **\*args** – the args to pass

Returns: the result of the function call

construct\_txn(*function\_schema*, *function\_name*, *args*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Constructs a transaction for the given function\_schema, function name and args

Parameters:

* **function\_schema** – Dict\[str, List\[str]], the schema for the function
* **function\_name** – str, the name of the function to be called
* **args** – Union\[List\[str], Dict\[str, str]], the args to be passed to the function

Examples shown in relayer\_tests/interface\_tests/test\_scrt\_interface.py, under the test\_basic\_txn\_construction and test\_dict\_txn\_construction tests

Returns:

a StdSignMsg (unsigned) transaction for the given function\_schema, function name and args

get\_function(*function\_name*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Returns the function schema for the given function name

Parameters:

**function\_name** – which function to get a list of args for

Returns:

the schema for the specific function

parse\_event\_from\_txn(*event\_name: str*, *logs: List\[TxLog]*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Parses the given event from the given logs

Parameters:

* **event\_name** – which event to parse
* **logs** – the logs to parse from

Returns: a list of tasks corresponding to parsed events

*class* scrt\_interface.SCRTInterface(*private\_key=''*, *address=None*, *api\_url='<https://api.pulsar.scrttestnet.com>'*, *chain\_id='pulsar-2'*, *provider=None*, *\*\*kwargs*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Bases: `BaseChainInterface`

Implementation of the BaseChainInterface standard for the Secret Network

get\_last\_block()¶

Returns the most recent block height Returns: the height of the current block

get\_transactions(*address*, *height=None*)¶

Returns all txn logs from the given height for the given address

Parameters:

* **address** – the address to get the txn logs for
* **height** – which height to get the txn logs from, if None, get all txn logs from the current height

Returns:

a list of txn logs for the given address/height

sign\_and\_send\_transaction(*tx*)¶

Signs and broadcasts a transaction to the network, returns the broadcast receipt

Parameters:

**tx\[StdTx]** – transaction to be signed and sent

Returns:

the receipt of the broadcast transaction

### TNLS-Relayers.web\_app module¶

web\_app.app\_factory(*config\_filename*, *config\_file\_converter=\<function generate\_full\_config>*, *num\_loops=None*)¶

Creates a Flask app with a relayer running on the backend

Parameters:

* **config\_filename** – Which filepath to pull config from
* **config\_file\_converter** – How to convert that config file into relayer config
* **num\_loops** – How many times the relayer should run before shutting down, None=Infinity

Returns: a flask app

web\_app.generate\_eth\_config(*config\_dict*, *provider=None*)¶

Converts a config dict into a tuple of (chain\_interface, contract\_interface, event\_name, function\_name) for ethereum

Parameters:

* **config\_dict** – a dict containing contract address, contract schema, and wallet address
* **provider** – an optional API client

Returns: the relevant tuple of chain, contract, event, and function

web\_app.generate\_full\_config(*config\_file*, *provider\_pair=None*)[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Takes in a yaml filepath and generates a config dict for eth and scrt relays

Parameters:

* **config\_file** – the path to the relevant config file
* **provider\_pair** – a pair of scrt and eth providers, optional

Returns:

a dict mapping scrt and eth to their respective configs

web\_app.generate\_scrt\_config(*config\_dict*, *provider=None*)¶

Converts a config dict into a tuple of (chain\_interface, contract\_interface, event\_name, function\_name) for secret

Parameters:

* **config\_dict** – a dict containing contract address, contract schema, and wallet address
* **provider** – an optional API client

Returns: the relevant tuple of chain, contract, event, and function

web\_app.index()[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Returns: a string form of the relayer

web\_app.keys()[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Returns: the current encryption and verification keys

web\_app.task\_json()[¶](broken://pages/rvFlthyVgbirkFr3ISub)

Returns: The status of the relayer
