1. blockexplorer Module

‘blockexplorer’ is the most important module in blockchain package which has Ten inbuilt functions to perform Blockchain manipulation operations. To import the package to our Python code we can use the following code.

1) get_block()

get_block is used to access a block from blockchain using the blocks hash value. The function will return the accessed block.

Parameters

2) get_tx()

You can get a transaction object from a blockchain using ‘get_tx’ function. Pass the transaction hash as a parameter to specify the object.





Parameters:

tx_id : str - transaction hash

Example:-

from blockchain import blockexplorer

transaction =blockexplorer. get_tx('726962b93d0f233d144dc9c8ada3a49251df804a135e43df5e8ac8e33182f98')





3) get_address()

This method is used to return a single address and all its transactions.by specifying a block address.

Parameters:

address: str - address(base58 or hash160).

filter: FilterType - The filter for transactions selection (not mandatory)

limit: int - The number of transactions to display (not mandatory)

offset: int - The number of transactions to skip (not mandatory)```

example:-

Address1 =blockexplorer.get_address('k47ghd5kqwrui4984yfny4vbi3yevf')





4) get_block_height()

This function will return an array of block objects at the specified height.

You can get an array of block object with ‘get_block_height()’ method. Pass the number of blocks as a parameter.

Parameters:

height: int - block height

Example:-

height1=blockexplorer .get_block_height('20158')





5) get_xpub()

Get an extended public key object and all its transactions using ‘get_xpub()’ method. The method takes one mandatory and three optional parameters as below.

Parameters:

xpu: str xpub to look up filter : FilterType - The filter for transactions selection (Not mandatory) limit : int - Number of transactions to display (Not mandatory) offset : int - The number of transactions to skip (Not mandatory) example:- xpubs=blockexplorer.get_xpub('p37fhfkg82hb7rw6eb1dnd983bvyd1yu227cb3ve8f93nnu7tvbs3nh a5srt7dds9fu8f')





6) get_multi_address()

You can use ‘get_multi_address()’ method to get a multi-address object containing the summary of multiple addresses. The object also returns overall balance, per address balance etc.

Parameters:

addresses : tuple - addresses(base58 or xpub) to look up

filter : FilterType - The filter for transactions selection (not mandatory)

limit : int - The number of transactions to display (not mandatory)

offset : int - number of transactions to skip (not mandatory)

example:-

addresses=blockexplorer.get_multi_address('7rw6eb1dnd983bvyd1yu227c’,’p37fhfkg82hbb3ve8f’,’93nnu7tvbs3nha5srt7’,r5thja3bf0j18gfjhgds9fu8f')





7) get_unspent_outputs()

You can get the details of all ‘UnspentOutput’ objects using this method.

Parameters:

addresses: tuple addresses - addresses in the base58 format or in ‘xpub’ format

confirmations: int - minimum number confirmations to include (optional)

limit : int - number of unspent outputs to fetch (optional)

example:-

unspent=blockexplorer.get_unspent_outputs('7rw6eb1dnd983bvyd1yu227cmdu73hfjfiterhendt34’)





8) get_latest_block()

Get the details of the latest block added in Blockchain using ‘get_latest_block()’ method.

example:-

latest=blockexplorer.get_latest_block()





9) get_unconfirmed_tx()

You can access the details of all unconfirmed transaction objects using ‘get_unconfirmed_tx()’ method.

example:-

latest=blockexplorer.get_unconfirmed_tx()





10) get_blocks()

This function will return an array of ‘SimpleBlock’ objects for a specified day or for a specified mining tool.

Parameters: