pypergraph.network package

Subpackages

Submodules

pypergraph.network.dag_network module

class pypergraph.network.dag_network.DagTokenNetwork(network_id: str = 'mainnet', l0_host: str | None = None, currency_l1_host: str | None = None, client: RESTClient | None = None)[source]

Bases: object

config(network_id: str = None, block_explorer_url: str | None = None, l0_host: str | None = None, currency_l1_host: str | None = None)[source]

Reconfigure the network; new configuration is applied only if different from the current one.

async get_address_balance(address: str) Balance[source]
async get_address_last_accepted_transaction_ref(address: str) TransactionReference[source]

Get the last transaction hash and ordinal from DAG address.

Parameters:

address

Returns:

Object with ordinal and transaction hash.

async get_latest_snapshot() Snapshot[source]

Get the latest snapshot from the block explorer.

Returns:

Snapshot object.

get_network() Dict[source]

Returns the DagTokenNetwork NetworkInfo object as dictionary.

Returns:

Serialized NetworkInfo object.

async get_pending_transaction(hash: str) PendingTransaction[source]

Check if the given transaction is pending.

Parameters:

hash

Returns:

Object if transaction is pending, else log error.

async get_transaction(hash: str) Transaction[source]

Get the given transaction from the block explorer.

Parameters:

hash – Transaction hash.

Returns:

BlockExplorerTransaction object.

async get_transactions_by_address(address: str, limit: int | None = None, search_after: str | None = None) List[Transaction][source]

Get all address-specific transactions from a given timestamp.

Parameters:
  • address – DAG address.

  • limit – Limit per page.

  • search_after – Timestamp.

Returns:

List of BlockExplorerTransaction objects.

async post_delegate_stake(tx: dict) str[source]

Delegate stake on L0. I believe this is a one-time thing for node operators to make the node available for delegated stake?

Parameters:

tx – Signed transaction.

Returns:

Transaction hash.

async post_transaction(tx: SignedTransaction) str[source]

Post a signed transaction to layer 1.

Parameters:

tx – Signed transaction.

Returns:

Transaction hash.

set_network(network_info: NetworkInfo)[source]

pypergraph.network.metagraph_network module

class pypergraph.network.metagraph_network.MetagraphTokenNetwork(metagraph_id: str, l0_host: str | None = None, currency_l1_host: str | None = None, data_l1_host: str | None = None, network_id: str | None = 'mainnet', block_explorer: str | None = None, client: RESTClient | None = None)[source]

Bases: object

Network instance used to interact with Constellation Network layer 0 and Metagraph currency and data layers. Can be used as a separate instance or as ‘network’ in MetagraphTokenClient.

async get_address_balance(address: str) Balance[source]

Get the current balance of a given DAG address.

Parameters:

address – DAG address.

Returns:

Balance object.

async get_address_last_accepted_transaction_ref(address: str) TransactionReference[source]

Get the last transaction hash and ordinal from a DAG address.

Parameters:

address – DAG address.

Returns:

Object with ordinal and hash.

async get_data()[source]

NOT IMPLEMENTED YET! Get data from Metagraph data layer 1.

Returns:

Data extracted from the response or None.

async get_latest_snapshot()[source]

Get the latest snapshot from Metagraph.

Returns:

A snapshot (type currency).

get_network() Dict[source]

Returns the MetagraphTokenNetwork NetworkInfo object as a dictionary.

Returns:

Serialized NetworkInfo object.

async get_pending_transaction(hash: str | None) PendingTransaction | None[source]

Check if the given transaction is pending.

Parameters:

hash – The transaction hash.

Returns:

PendingTransaction object if found; otherwise, None.

async get_transaction(hash: str | None) Transaction | None[source]

Get the given transaction.

Parameters:

hash – Transaction hash.

Returns:

BlockExplorerTransaction object or None.

async get_transactions_by_address(address: str, limit: int | None = None, search_after: str | None = None) List[Transaction] | None[source]

Get a paginated list of Block Explorer transaction objects.

Parameters:
  • address – DAG address.

  • limit – Limit per page.

  • search_after – Timestamp to paginate.

Returns:

List of BlockExplorerTransaction objects or None.

async post_data(tx: Dict[str, Dict]) dict[source]

Post data to Metagraph. Signed transaction should be in the format:

{

“value”: { … }, “proofs”: [

{

“id”: “c7f9a08bdea7ff5f51c8af16e223a1d751bac9c541125d9aef5658e9b7597aee8cba374119ebe83fb9edd8c0b4654af273f2d052e2d7dd5c6160b6d6c284a17c”, “signature”: “3045022017607e6f32295b0ba73b372e31780bd373322b6342c3d234b77bea46adc78dde022100e6ffe2bca011f4850b7c76d549f6768b88d0f4c09745c6567bbbe45983a28bf1”

}

]

}

Parameters:

tx – Signed transaction as a dictionary.

Returns:

Dictionary with response from Metagraph.

async post_transaction(tx: SignedTransaction) str | None[source]

Post a signed transaction to Metagraph.

Parameters:

tx – Signed transaction.

Returns:

Transaction hash.

Module contents

class pypergraph.network.DagTokenNetwork(network_id: str = 'mainnet', l0_host: str | None = None, currency_l1_host: str | None = None, client: RESTClient | None = None)[source]

Bases: object

config(network_id: str = None, block_explorer_url: str | None = None, l0_host: str | None = None, currency_l1_host: str | None = None)[source]

Reconfigure the network; new configuration is applied only if different from the current one.

async get_address_balance(address: str) Balance[source]
async get_address_last_accepted_transaction_ref(address: str) TransactionReference[source]

Get the last transaction hash and ordinal from DAG address.

Parameters:

address

Returns:

Object with ordinal and transaction hash.

async get_latest_snapshot() Snapshot[source]

Get the latest snapshot from the block explorer.

Returns:

Snapshot object.

get_network() Dict[source]

Returns the DagTokenNetwork NetworkInfo object as dictionary.

Returns:

Serialized NetworkInfo object.

async get_pending_transaction(hash: str) PendingTransaction[source]

Check if the given transaction is pending.

Parameters:

hash

Returns:

Object if transaction is pending, else log error.

async get_transaction(hash: str) Transaction[source]

Get the given transaction from the block explorer.

Parameters:

hash – Transaction hash.

Returns:

BlockExplorerTransaction object.

async get_transactions_by_address(address: str, limit: int | None = None, search_after: str | None = None) List[Transaction][source]

Get all address-specific transactions from a given timestamp.

Parameters:
  • address – DAG address.

  • limit – Limit per page.

  • search_after – Timestamp.

Returns:

List of BlockExplorerTransaction objects.

async post_delegate_stake(tx: dict) str[source]

Delegate stake on L0. I believe this is a one-time thing for node operators to make the node available for delegated stake?

Parameters:

tx – Signed transaction.

Returns:

Transaction hash.

async post_transaction(tx: SignedTransaction) str[source]

Post a signed transaction to layer 1.

Parameters:

tx – Signed transaction.

Returns:

Transaction hash.

set_network(network_info: NetworkInfo)[source]
class pypergraph.network.MetagraphTokenNetwork(metagraph_id: str, l0_host: str | None = None, currency_l1_host: str | None = None, data_l1_host: str | None = None, network_id: str | None = 'mainnet', block_explorer: str | None = None, client: RESTClient | None = None)[source]

Bases: object

Network instance used to interact with Constellation Network layer 0 and Metagraph currency and data layers. Can be used as a separate instance or as ‘network’ in MetagraphTokenClient.

async get_address_balance(address: str) Balance[source]

Get the current balance of a given DAG address.

Parameters:

address – DAG address.

Returns:

Balance object.

async get_address_last_accepted_transaction_ref(address: str) TransactionReference[source]

Get the last transaction hash and ordinal from a DAG address.

Parameters:

address – DAG address.

Returns:

Object with ordinal and hash.

async get_data()[source]

NOT IMPLEMENTED YET! Get data from Metagraph data layer 1.

Returns:

Data extracted from the response or None.

async get_latest_snapshot()[source]

Get the latest snapshot from Metagraph.

Returns:

A snapshot (type currency).

get_network() Dict[source]

Returns the MetagraphTokenNetwork NetworkInfo object as a dictionary.

Returns:

Serialized NetworkInfo object.

async get_pending_transaction(hash: str | None) PendingTransaction | None[source]

Check if the given transaction is pending.

Parameters:

hash – The transaction hash.

Returns:

PendingTransaction object if found; otherwise, None.

async get_transaction(hash: str | None) Transaction | None[source]

Get the given transaction.

Parameters:

hash – Transaction hash.

Returns:

BlockExplorerTransaction object or None.

async get_transactions_by_address(address: str, limit: int | None = None, search_after: str | None = None) List[Transaction] | None[source]

Get a paginated list of Block Explorer transaction objects.

Parameters:
  • address – DAG address.

  • limit – Limit per page.

  • search_after – Timestamp to paginate.

Returns:

List of BlockExplorerTransaction objects or None.

async post_data(tx: Dict[str, Dict]) dict[source]

Post data to Metagraph. Signed transaction should be in the format:

{

“value”: { … }, “proofs”: [

{

“id”: “c7f9a08bdea7ff5f51c8af16e223a1d751bac9c541125d9aef5658e9b7597aee8cba374119ebe83fb9edd8c0b4654af273f2d052e2d7dd5c6160b6d6c284a17c”, “signature”: “3045022017607e6f32295b0ba73b372e31780bd373322b6342c3d234b77bea46adc78dde022100e6ffe2bca011f4850b7c76d549f6768b88d0f4c09745c6567bbbe45983a28bf1”

}

]

}

Parameters:

tx – Signed transaction as a dictionary.

Returns:

Dictionary with response from Metagraph.

async post_transaction(tx: SignedTransaction) str | None[source]

Post a signed transaction to Metagraph.

Parameters:

tx – Signed transaction.

Returns:

Transaction hash.