 Hi. Hi guys. So, welcome to this talk about Ethereum, Bitcoin, RPC APIs. So, if you remember in the last talk, he mentioned about JSON RPC APIs in the presentation. So, I am planning to go deeper into that topic with Ethereum and Bitcoin, how that JSON RPC is working and how you can connect to those APIs with your own node without using any third party like blog explorer or else either scan or someone else third party APIs. So, this will be good for programmers, developers who would like to start working on Ethereum, Bitcoin stuff after this conference or else from today onwards. So, it will be a good chance for you to start your career with blockchain things. So, I am Dilumna Anjana and this is my Github and this is my Twitter. If you have any questions after this talk, you can just tweet me and I will reply. I am from even though I am working here in Singapore, I am from this little South Asian island called Sri Lanka. Hope at least you have heard about Sri Lanka and in Sri Lanka we have nice beaches and we have deep plantations and especially we have elephants. And I am a Cody member of Celluloid. If you haven't heard about Celluloid, Celluloid is a concurrency and parallel processing third party tool or else a gem in Ruby working with Ruby foundation. So, I am a Cody member of Celluloid working with them and going around Asia talking about concurrency, parallel processing, but here today I am talking about blockchain stuff. And according to the Ruby foundation's founders definition, I am a Rubyist. And here in Singapore I am working in a startup called Beebytes and mainly we are working with Ruby stuff, Ruby backend development, APIs and everything. And also especially we are working with blockchain, private blockchains, public blockchains like private blockchains like big chain DB and we are working with Ethereum, Bitcoin, smart contracts so on. Yes. We are hiring yes. If any of you are familiar with developments with big blockchain and any decentralized payment platforms, yes we would like to talk with you. So, after this talk or else I will be here around this conference maybe today and tomorrow and Sunday. So, just come to me and talk to me. We are hiring. And we have our own ICO up and running these days for a future plan of having a decentralized payment platform. So, it is bigtk.io. If you would like to have how big token is going to disrupt this decentralized payment platform or else how we are going to have our own tokens just have a look. And this is a technical presentation. But I am not going to define what is cryptocurrency or else I am not going to define what is Bitcoin or else what is Ethereum because we have just 20 minutes, 25 minutes and you can just go to Google and just search for those things. But as developers we all love APIs. So, when we start working on something if we want to learn new things the first thing that we would like to search in online is APIs. Are there any exposed APIs for this technology or else for this framework that we can use in our existing services or else applications. So, that is what I also did when I was assigned to some blockchain works with Ethereum and Bitcoin in my workplace. So, then as I checked all cryptocurrencies I checked have APIs exposed from their nodes Bitcoin, Ethereum, Litecoin so on. So, to use or else to consume those APIs to consume those RPC APIs we need a node up and running or else a demon up and running. For testing purposes I prefer to have a docker container which runs those demons or else nodes. This is the Bitcoin demon container that I created for my testing purposes if you would like to have a look. It is just a Bitcoin demon inside a container and you can just start this docker container and consume those RPC APIs. It is open source just have a look and if you want you can use it as well. And this is the Ethereum docker container that I used. Actually I created this Ethereum container. Inside this container they are Ethereum node running. So, it is easy for you. You do not have to install any gate or else any C++ libraries. All of them are inside this container. You just have to run this docker container and it will be the node will be up. But you have to start syncing your node up after running this container or else if you would like to have your own demon or else node you can run you can install whatever the things that you need to install before running the demon and then start running your own demon. So, you have your own demon or else node running in your local host. So, after that connecting to this RPC APIs as like as simple as running this curl command to this port in your local host. So, that it is that much of simple to connect to those RPC APIs. So, Ethereum has their own inter-process communication IPC APIs and as well as remote procedure call RPC because RPC APIs exposed and Bitcoin has their own remote procedure calls only and this is the Bitcoin RPC API documentation and this is more. So, if you want to just look at how this APIs works RPC APIs works just go to those documentations and you can see there are like so many APIs exposed from these RPC API APIs from the nodes and you can use those APIs to have like your own like a Bitcoin client or else something that you can use for your own use or else to there are so many things that you can do and this is the Ethereum RPC API documentation link. So, you can just go there and this is a common RPC API that you can use if you are consuming those APIs you do not need to unlock your any of your wallets you can just use those APIs and consume those transaction like you can get block details using the block hash or else you can get the transaction details using the transaction hash you do not have to unlock your wallet for those kind of information or else you can get your account account means wallet IDs inside this node and also you can get whatever the wallets balance using those APIs. So, this is the API documentation detailed documentation for get balance. So, there are two parameters you have to pass. So, the wallet ID and as well as the if you want to get the latest balance you have to pass latest. So, then you can get any of the wallets Ethereum wallets balance from using this API and this is the Ethereum management API which is more powerful than the normal APIs. This management APIs we can use for your wallet related things like unlock your wallet lock your wallet or else create a new wallet and send a transaction especially if you would like to use this API to send a transaction you can use that as well from like if you want to send a transaction programmically from like from your server application side without using any graphical client you can use those APIs to send the transaction, but to send the transaction you have to unlock your wallet using that unlock API and then you can send those transactions. So, this is the API detailed documentation what you have to pass to unlock your wallet you have to pass the wallet ID and as well as the wallet pass phase and then how many seconds you need this wallet to be unlocked. So, this is in this example it is 30 seconds. So, after 30 seconds your wallet will be locked automatically default is around 300 seconds as I remember. So, because I love Ruby and I am working with Ruby most of the time using this RPC APIs for Bitcoin and Ethereum right now I created a gem called El Chapo. So, this is actually a Ruby wrapper for this RPC API if you would like to have and any of you are familiar with Ruby or else if any of you are any of you would like to learn Ruby and using Ruby in your server side then this will be a good chance for you to use those RPC APIs in Ruby very easily other than just calling press clients. The name this El Chapo is coming from some funny stories and the reason is one day I can come to a conference like this and I can say to people that I am the creator of El Chapo. So, that is the reason this gem called El Chapo came to me and this is the gem how it works you can create Bitcoin HTTP connection new and you have to send the URL and the port and as well as when you are running starting your Bitcoin node you have to send you have to mention your username and password for the RPC client and you have to pass this username the same username and password for this Bitcoin wrapper. So, then using this BTC underscore client you can use those RPC APIs as a method call in your Ruby code. So, then I managed to do my connection between my Ruby server side rails server side and as with Bitcoin or else Ethereum client. So, my work office related work is done, but on a weekend I was so bored and I didn't have any plans to do and because I had this gem with me and I wanted to do something interesting. So, I got the idea to convert blockchain to convert a blockchain to SQL. So, this is my initial idea, but then I managed to like do this to something like this. So, this is my initial this was my initial plan few months ago to convert all Bitcoin transactions to SQL. So, the reason that I wanted to do convert everything to SQL is to find the highest transaction value happened inside Bitcoin. So, today I will tell you what are the what are those transactions happened in this Bitcoin and what is the date and everything. So, after converting. So, last week I managed to finish all the conversion from the block 1 to 500k plus right now. So, what I did was I was going through the blocks from 0 to 500k plus from a Ruby just from a Ruby script and this is an example that I am getting for a Bitcoin block. So, it has so many information like the Bitcoin hash block hash and the size and everything and then the most important thing is the transactions IDs hash hashes for this block. So, it is an array and inside once I found this transaction IDs then I iterate through those transactions and this is what I get for the transaction row details. So, each transaction I get who is the sender who is the receiver and what is the value and everything. So, I wrote the Ruby script and I used active record to save it to my SQL and then this is a example of my database I am saving the block number and transaction ID the block hash and the most important thing is the value and the transaction created date and updated is the that I updated the date and sender receiver and the balance receiver. So, I had all details of these for all transactions of Bitcoin right now. So, initially I thought it will take maximum 5 days, but I was wrong it took me around like more than one month to finish everything. So, on the process after like two weeks I realized my script was not the most powerful script that I could run to convert everything. So, I used a gem or a method called bulk insert to insert 500 transactions by 500 transaction to my my SQL database which makes it little bit faster, but not fast enough to finish it within few days. So, by last week actually I managed to finish everything. So, the database contained 236,915,620 transactions and the database size is 76.63 GB my SQL database this is some example and my initial plan was to find the highest value transferred within Bitcoin and few more researchers after going on with my database because I have the sender and I have the receiver. So, like I have some more information about the transaction happened through the day Bitcoin network. So, this is the highest transaction happened within 2009. So, within 2009 the year of 2009 the highest value transferred is 6000 bitcoins it happens on this day. So, I will go through the year by year first of all and then I will give you what is the highest value. And in 2010 it is 90000 bitcoins the the transaction happened on November 9th 2010 and 2011 it is almost 500k Bitcoin. So, it is happened on November 16th 2011 and in 2012 it went down to 125,000 bitcoins transferred on this day in a transaction and 2013 it is this and 14 it is this 15 it is this 16 it is this and 17 it is 50,000 exactly 50,000 transferred on August 2nd August 2nd 2017 which was about like 8 months ago. And so, the highest transaction of all the time what goes to the transaction happened on 2011 November 16th on block in this block that is 499,720.7 bitcoins transferred. So, if you go to this block on block explorer you can see that transaction on this block there were like about three transactions and one transaction is this transaction. But the highest transaction value in USD so, at the transaction time if you take this transaction converted into USD in 2011 it was about like 2 million USD which was not the best in comparing to other transactions. So, the highest transaction value in USD what goes to this transaction 2017 50 50,000 bitcoins. So, in this I checked the price of bitcoin on August 2nd 2017 on that day it was about 2700 USD the one bitcoin and because of that that transaction value in USD is about 135 million USD transferred on that day which was like 8 months ago. And if you want to check all the transaction details I have this is my blog I have mentioned all the block explorer transaction URLs they are in a blog post with all those years transactions and everything. So, if you want to have a look detail look on those transactions just go to this just go to my blog and it will be there. Okay, I think it is done and any questions. Did you write any indexes? No, I am planning to write some indexes yes because so, right now if I write a query for searching the highest value within this it takes like 3 minutes to complete the query. So, it is yeah I need to write some indexes. Yes, I have some plans I do not need to keep it secret as a database with me I would like to share this database. So, because it I got this database last week I will upload it to somewhere and like first of all I need to check how I can compress the database into 7C or something and then I will try it with public yes for sure. Yes, I can do it like not right now but so, right now the speed of converting everything is I can convert one month transactions within one day. So, like I have almost until the start of this month transactions converted. So, if I run like one day it will be synced and like yes, because I am using one of my personal machines to do this right now the script is stopped, but if I start it will start syncing every day. I need to create a graph from actually what I need to do is so, because I have all the transactions with me I need to calculate who has the highest value in his wallet in user's wallet right now and maybe I will sort from highest to lowest the wallets and then maybe I will publish and I will write a blog post. So, your Docker client downloads the whole chain? Yes. So, my Docker client I was using it for my testing purposes but the Docker client in the main network couldn't handle that much of syncing database in Bitcoin. So, I had to use my own Docker Bitcoin daemon inside my machine. I am not pretty much sure yes it is the normal size around like 200 GB as I remember. Yeah, it is over 200. Yeah. Any questions? Yes. Are you going to expose your HTTP APIs you created in any way to public so that you don't have to download the blockchain? The transactions? No, just your API because you already have the blockchain on your machine. Yes. So, those APIs are public APIs those RPC APIs. Your web? My database, the SQL database I downloaded, is it? No, it's not me downloading the blockchain to my machine. Can I just simply access your new Ruby? That's a Ruby wrapper actually. If you have a node running and then only you can connect to your node using my wrapper, yeah. You have a quick check. So, here's a share of this API access blockchain, Bitcoin blockchain is very good above everyone. So, I think if a few of you can do this, then upload the whole blockchain into the website database and share your API to us so you can call them and call them for the history. Yeah. What do you want? Maybe the transaction within this month, how many transactions will be sent out? How many transactions will be from the exchange or with the M kind of thing? Yes, that's true. Yes, I have some plans because I have all the senders and receivers. Maybe so one of the researchers contacted me asked me to create some using this database, something like if you remember that Windows virus that got affected last year ransomware. So, they asked to pay them using Bitcoin. So, if you have some way that we can track those that Bitcoin wallets and check those wallets, how they spend their wallet money and those kind of things. So, if I use this database for those kind of things. So, I might do some graphs, something like that. If you enter a wallet ID, then you can see what are the past transactions he got and what are the things that he spent on and where he spends on like what are the other wallets that he connected and everything. So, which will be like more interesting for the people. Yes. Okay. Yeah. Thank you.