⛏
EthMine Basic Ethereum Miner Library.
Developers can integrate this algorithm to mine blocks from their ethereum supported chain efficiently.
⬇️
Installation This Algorithm can be implemented for EthTrade for more functionality and interaction with the live Ethereum Chain. The link can be found under the "More Information" section.
This algorithm works for all versions of Python, but is recommended to run on Python3 due to functionalities of external libraries.
Installation Command: pip install ethminer
Note: Use pip3
if running on Python3.
Integrating the Library to the Project: from etherminer import EtherMine
⚙️
Functionality EtherMine
can be named into a separate object variable, but for example cases, EtherMine
will be used for reference.
There are a few functions and commands that help users and developers interact with the chain right from their local host. Do note however, it is required to have an infura url that is live in order to interact with the chain. If you don't know what infura url is, or do not know how to use infura url, click on the link of their documentation unde the "More Information" section.
🔧
Connecting to the Chain As stated above, to connect to the chain, users must have an infura url ready to be inputted. This infura url is a link that connects to their project on infura itself.
To connect to the chain: EtherMine.connect_chain()
Note: For the rest of the commands to work, users must be connected to the chain in order for full functionality.
💡
Getting Latest Block Users can view and mine the latest block of the Ethereum chain in real time. However, there may be some latency depending on the connection of the chain to the user's network.
To get the latest block: EtherMine.get_top_block()
This command will return the latest block in constant time. Moreover, all the blocks viewed will be added to local array data structure that can be returned to view and use various blocks of the chain.
Getting Multiple Blocks 🙌🏻
Users can also retrieve a desired number of recent blocks on the chain. They will be prompted to type in the number of blocks they would like to see.
Syntax: EtherMine.get_multiple_blocks()
Similar to getting the latest block, all the blocks will be added to the local user array of saved blocks.
🧱
Viewing Blocks The users can view all their past blocks they have seen using the commands listed above.
Syntax: EtherMine.view_blocks()
This command may be a little heavy depending on how many blocks the user has saved, however, all the information will be outputted, which can be used for anything, such as the local mining procedure this library has to offer. This array can be used for multiple applications as it is returned rather than being printed.
💎
Mining Users can also mine a block with the in-built mining function. Depending on the performance of the user's machine, the mining process can be a little bit heavy for some users, but does work for all systems.
To mine: EtherMine.mine(block_number, from_account_hash, transaction_hash, previous_hash, difficulty)
This command does have some pre-requisities as inputs:
block_number
: The number of the block the user would like to mine.from_account_hash
: The original owner of the blocktransaction_hash
: The transaction hashprevious_hash
: The previous transaction hash of the blockdifficulty
: The difficulty of the block
All this information can be found using the platform EthTrade (view the "More Information" section for more information)or using the functions listed above. However, note that if the user does use the functions above, some information may not be all available.
If the mining is unsucessful, the algorithm will return None
, else, it will return the hash of the block along with the nonce value.
📚
More Information This library is full functional for all operating systems. However, this algorithm may not work for all Web3 library versions.
Infura: https://infura.io Library on PyPi: https://pypi.org/project/ethminer/ EthTrade: https://github.com/GEEGABYTE1/EthTrade
Made with