This project generates accounts for both Bitcoin and Ethereum from private keys, that can then be used to transact with.
The installation of the pip dependencies "bit" and "web3" are as follows:
$ pip install bit
That command will install bit to be used with python. Use the following command to confirm installation, as well as finding out which version of bit was installed:
$ pip list | grep bit
To install web3, the command is as follows:
$ pip install web3
Similar to the bit library, that command will install web3 to be used with python. To confirm the installation, as well as checking the installed version, enter as follows:
$ pip list | grep web3
To clone and install the hd-wallet derive, enter the following:
$ git clone https://github.com/dan-da/hd-wallet-derive
$ cd hd-wallet-derive
$ php -r "readfile('https://getcomposer.org/installer');" | php
$ php composer.phar install
Lastly, you need to create a symlink called "derive" for the hd-wallet-derive/hd-wallet-derive.php script into the top level project directory like so:
$ ln -s hd-wallet-derive/hd-wallet-derive.php derive
You simply run the wallet/wallet.py file from the command line using python.
$ python wallet.py
Lines 177 and 183 run the actual transactions, comment out 177 if you want to run a ETH transaction. Comment out 183 if you want to run a BTC transaction.
Lastly, after creating the address, I funded a BTC and ETH address testnet crypto.
For BTC, use this.
For ETH, use this.
Below is an image of a valie BTC-testnet transaction. It can be found on Blockchain here.
The code to run the transaction above is as follows:
send_tx(BTCTEST, btc_accounts["account_01"], btc_accounts["account_02"], 0.00000003)
(The code in that above instance could be altered to have transactions occur with different accounts. for example "account_02" and "account_03". Granted, they would also need to be funded.)
To achieve this, you would run:
$ python wallet.py
An example output is shown here:
The output is the transaction hash that can then be searched on Blockchain for the Bitcoin testnet, as previously demonstrated.
Below is an image of a valid ETH-testnet transaction. It can be found on Etherescan here.
The code to run the transaction above is as follows:
send_tx(ETH, eth_accounts["account_01"], eth_accounts["account_02"], 200000000000000)
(The code in that above instance could be altered to have transactions occur with different accounts. for example "account_02" and "account_03". Granted, they would also need to be funded.)
To achieve this, you would run:
$ python wallet.py
An example output is shown here:
The output is the transaction hash that can then be searched on Etherscan for the Ropsten testnet, as previously demonstrated.
- python - Programming language.
- python-dotenv - Reads the key-value pair from .env file and adds them to environment variable.
- hd-wallet-derive - CLI tool that derives bip32 addresses and private keys.
- Bit - Python Bitcoin library.
- web3.py - Python Ethereum library.
- Infura - API used to access the Ethereum and IPFS networks.
- subprocess - Module that allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.
- Roberto Cantu - GitHub