The goal of this project was to create a program using Mathematica that linked the Wolfram Language to the Bitcoin Blockchain. The Bitcoin Blockchain is a database that contains records of all the transactions in the history of Bitcoin. I chose to connect this to the Wolfram Language because I thought it would be an interesting application of Wolfram technology to have an external connection with a financial purpose and data analysis applications. The program I wrote uses two Blockchain.info (https://blockchain.info/) APIs to provide general Blockchain data, as well as to login and use personal wallets to conduct transactions.
I first started out by using the non-wallet based Blockchain.info API, called the Simple Query API (https://blockchain.info/q), to provide general data about the Blockchain. An example of this type of query is AddressBalance, which returns the balance of a wallet with a given address (all account balances and transaction data are public). I used some of my past experience with the Wolfram Language from the Mathematica Summer Program, which I attended during this past summer between my freshman and sophomore years in high school, to create a basic template for a Simple Query Mathematica function. The template starts with a definition of variables, then creates a CloudObject using the function's inputs. This CloudObject outputs the result of the query, and this result is returned to the user in Mathematica. Since some functions have more inputs, or different types of output, I modified this template for specific functions.
After this, I moved on to the wallet-based Blockchain Wallet API (https://blockchain.info/api/blockchain_wallet_api). Here, I had to first find a way to log into a wallet through Mathematica, so that I could access the various wallet-only functions, such as making an actual transaction. This part was relatively easy, but on January 1st, the Blockchain staff changed their API and added a package containing a server that would need to be installed in order to use the Wallet API. So, I had to download the package, and learn how to run the server from a terminal. This was only a minor drawback, and fortunately it only affected the Wallet API, so I didn't need to modify my Simple Query API functions. To make my Blockchain Wallet API functions, I first wrote a function, similar to the Simple Query API ones, which logs into a wallet, given its wallet identifier, password, and API key (necessary to run wallet-based functions). Then, I wrote a function to find the balance of an account, and another to make a transaction between two accounts.
Some challenges I faced were finding an appropriate API to connect to the Wolfram Language, and then testing the wallet-based functions I wrote. In order to test those functions, I had to have two Blockchain wallets, both with some amount of money. It took quite a while to find a secure method of transferring money from a Wolfram Research account into a Blockchain.info wallet, but in the end I was able to make transactions between the two accounts.
Thank you to Ms Alison Kimball, Mr Todd Rowland, Mr Christian Pasquel, and Mr Stephen Wolfram, for giving me this mentorship and helping me with this project.
I'd be happy to know more about your work and interest in this area.