Tesla Bitcoin Miner LIVE

Siraj Raval · Beginner ·🤖 AI Agents & Automation ·5y ago

Key Takeaways

The video demonstrates how to install a bitcoin mining client onto a Tesla's hardware, using tools like Node.js, Bitcoin, and Tesla, and explores concepts like decentralized technology, artificial intelligence, and reinforcement learning. It also covers the use of smart contracts, blockchain, and cryptocurrency trading.

Full Transcript

three five four go live three two one we're about to go live and here we go all righty all right hello world it's siraj and i am in my tesla and i've got this m1 mac mini that is mining bitcoin for me constantly and this m1 mac mini is attached to my car and what it's doing is it's using the it's using this um let me show you it's using this port right here to charge in so it's like an adapter and it's an ac outlet so it's powered it's literally powered by the tesla and the thing about the m1 mac mini is that it just sips power it doesn't need that much power so it's perfect for the tesla and so while this thing is on autopilot it's mining bitcoin for me it's not only is it mining bitcoin i wrote an ai you can see the link in the video description it's a reinforcement learning algorithm that predicts what the three next best all coins to invest would be it then converts that bitcoin into three of those all coins and then invest in those all coins every 24 hours it also pays for its own electricity using bitcoin which is amazing and i'll show you exactly what i mean like how does it pay for its electricity using bitcoin well it sends some money to my bit pay account which has a visa card attached to it that lets me spend bitcoins using visa and then on my tesla account i've attached this visa and this visa then pays for the electricity via supercharging but that visa is bought with bitcoin so it's like this closed-loop system of autonomy that we are creating using using decentralized technology and artificial intelligence let me show you exactly how i built this thing and let's talk about bitcoin all right so that was the little intro demo the bitcoin intro demo it's great to see you guys here i've got some three questions for you it's gonna be a lot of fun um we're gonna talk about bitcoin today because bitcoin just hit 40 000 for a single bitcoin today that is crazy and um my first ever youtube video i just want you to know on january 1st 2016 was literally called what is bitcoin if you want to see me five years ago click on that link in the video description i looked totally different and i was a very different person um but yeah bitcoin is not a scam it's not a ponzi scheme it's not a pyramid scheme it is the future of money and now everybody is beginning to understand that because the technology behind bitcoin is immutable it is so powerful you would need more computing power than the 500 fastest supercomputers on planet earth to break bitcoin and nobody has that much computing power and so bitcoin is a very secure network in this episode we're going to talk about how bitcoin works um and then we're going to build a node.js application the link to that is already in the video description that will autonomously mine bitcoin it will also reinvest its bitcoin into um different altcoins and it will also um turn that bitcoin into just save that bitcoin for personal use so it's going to do a lot of different things we're going to talk about how to do all of that with simple javascript and that includes a smart contract so there's a lot that we have to go over to even get to that demo in terms of what are all these dependencies that i'm talking about so let's start with this one right here so this is an image from my book decentralized application i put it in my book five years ago but it's probably the most important image that i can show you you know if you're a bitcoin beginner if you're somebody who really wants to understand what the purpose of this technology is long term take a look at this image what this image is is it shows two different types of organizations one that has internal capital and one that does not have internal capital so organizations that don't have internal capital would be open source projects where there is no you know revenue source maybe it's a maybe it's just a program there are no humans involved whatsoever and it's not generating any revenue but there's a new type of application that was enabled when bitcoin was created and that is called a decentralized application it you can also call it a decentralized autonomous organization because normally we have um ai at the edges of our organization and humans at the core making all the core decisions but in the future it's going to be ai at the edges and ai at the core which means humans are not necessary whatsoever decentralized uber decentralized airbnb decentralized literally everything it's going to happen in 2021. even if it's not because of the technology it's because of what the sec just enabled the sec just enabled two major things number one anybody can raise up to five million us dollars for crowdfunding before it was one million so the threshold has increased also now contractors can receive equity in companies that was not possible before so think about all the drivers for the uber network that are not getting any equity the next version of uber the decentralized uber that inevitably will come out this year will give drivers equity and when that happens those drivers are going to be more incentivized to work for the network and they'll switch over from uber this is just the future of money okay we have to completely rethink about what money is right what did kanye west say on rogan's podcast how much is the earth worth right think about that stupid statement for a second how much is the earth worth it's worth more than than there exist money we couldn't buy the earth because we invented money and people are beginning to realize how invented money is it's not in god we trust it's in encryption we trust so that's the deal with bitcoin and so we can use bitcoin to build these new types of applications for ourselves for our communities and for real-world applications and so that's what it does basically bitcoin enables us to create more autonomous organizations that need less and less humans that's the basic gist of the idea and that's what i'm doing with my own tesla i want my tesla to be a robot that pays for its own repairs it doesn't need me whatsoever it's just doing its own thing and so you know when it comes to ai and decentralized ai this is really the idea of decentralized ai where we have different models that are running on different computers and they're speaking to each other they're communicating their learnings to each other so anything that is being trained on locally let's say it's an image or video or something we want to keep that private we don't want everybody to see what that data is we can share the learnings in terms of the weight matrix that is learned over time with other people and when we do that it's faster for training so training is speed up is sped up we can also share valuable data in terms of medical images maybe it's electronic health records we want to train a convolutional network on say radiology images and the classification of what you know types of coronary disease are in those radiology images but we don't necessarily want to share the patient's information with everybody so that would be a great use case for decentralized ai where the ai the it's being trained on different devices these secure devices where the data cannot leave due to hipaa laws or some kind of law but you can share the learnings so that's one major use case of that and you know what i didn't even show you was uh the the initial demo that i had of of the um ai system but i'm gonna i'm gonna show that to you in a second let me just show you this last image first so and you know if you haven't yet go read my book decentralized applications harnessing bitcoin's blockchain technology i have been talking about this for many years and now i feel like our time has come our time has come for this fully automated future and the future of money is here the future of intelligence all these trends are are coming together and i thought they would happen years ago but it's not years ago i was too early now it's happening 2021 is the year of decentralized applications and mark my words the first unicorn company will emerge this year and it's going to be a crowdfunded company it's not going to be a venture-backed company we are democratizing opportunity and access to everything skills training services everything is being decentralized more and more people are becoming more and more capable using these technologies now before we get to the code and before we get to the questions i want to show you one more thing and that is the um file that i have here all righty all right hello world it's garage and i am in my tesla so this is i've got this it's called m1 mac mini it's called mining bitcoin car right foreign and what it's doing is using the mining it's using this um let me show you you know a couple of things right here um and the thing about the m1 mac mini is that it just sits power it doesn't need that much power it's perfect for the tesla and so while this thing is on auto mining bitcoin for me it's not only and the audio is overlapping okay there we go no overlapping audio so um okay so now let's build this application we're going to build this application together it's going to be a node.js web app and we're going to put this node.js web app on the m1 device the m1 device is connected to my tesla so it's powered by the tesla the tesla is just feeding it electricity and as it's feeding in electricity the m1 is mining bitcoin in real time the node.js web app is taking those mined bitcoins and it's intelligently reinvesting those bitcoins in three areas number one it's reinvesting them into my own account so that's just personal capital number two it's reinvesting them into these altcoins like ethereum or like ltc or you know name your altcoin it's using reinforcement learning to pick which altcoins to uh invest in and the third and last thing is that it's paying for its own electricity because i have bitpay so it's bitcoin to visa to the tesla network so there's an intermediary step but it's really a proof of concept so that's the basic idea and so now what we're going to do is we're going to look at this script we're going to build a script in node.js together that will be able to just do everything that i just said so where do we begin with the node.js script well we begin by going to my github repository and then we will talk about that all right so let's move that over here so yeah if you haven't yet check out the github repository for this code it's a node.js web app that i wrote literally in like six like 12 hours yesterday just like before the live stream just because i've been doing so much for code royale we're nearing release of the game just working with you know my co-founder on uh development raphael dick reuter on development of this and you know he's been working so hard and it's uh it's it's really it's all coming together so i'm really excited about that and so i haven't had as much time to prepare for this live stream but i did write this code so it's not the best code but it works it's all pure javascript and you know the thing i like about javascript is just how fast you can build literally anything in javascript and have it um just work locally on your computer and so um by the way i also want to say that i'm not using the default tesla hardware to mine because it is locked and i don't want to void my warranty i did buy the full self-driving capability for like 10k usd and i'm not about to lose that money by hacking into the tesla and then tesla's like hey elon's like no no no siraj you're not supposed to do that i saw your youtube video so elon it's all good if you're watching don't worry um i did not void that warranty so i'm using a separate computing device but it's powered by the tesla in fact you can do this with a gas car you know as long as you have an ac outlet converter but you won't be able to pay for your own gas i mean i guess you could think of a scheme to do that actually so it's not just tesla specific tesla just makes it easier because it's electric and it's a computer car so um we have to build this web app so let's let's do that we're going to build this web app it's going to be a node.js web app and we're going to do that from scratch so um that is the thing but before we get to the web app i have to ask you the first question we're about to start coding but i have i have a question for you i need to make sure that you've been listening so you can win some bitcoin what does that sound like sounds good right people have been winning bitcoin every single week i hope some of you guys have been holding on to your bitcoin because that price is just going to keep going up obviously nobody has a crystal ball but it's going to keep going up so um let's see what is the first question that i'm going to ask you guys well the first question that i'm going to ask you guys is the first question is oh my god what's happening here hold on hold on okay begin accepting answers okay this is going to take a while i know but you can go to now it's going to work so um here's what the question is so the question is this the question is which of the following statements regarding bitcoin is true a it's possible to create fake bitcoins on your home computer b bitcoin's consensus algorithm is called proof of work c bitcoin is the only cryptocurrency that offers mining or d bitcoin was invented by yours truly one of these is correct and the others are not so while you answer that let me answer three questions from the audience question one is from danish rijwani he asks is it worth still mining anything if the price crashes again is the bitcoin crash inevitable like before so those of us who are crypto i guess you could say veterans at this point the price of bitcoin always goes up and down that's inevitably up and down up and down but like it doesn't matter how much of an expert you are in bitcoin nobody can predict the price right because the events that are happening right now in the united states nobody could have predicted and just nobody knows where everything is going right nobody can know so is it inevitable no it's not inevitable the crash is not bitcoin could go to a million dollars tomorrow you know nobody knows so don't listen to anybody who says bitcoin will do this you know don't listen to anybody because it can go down it can go up just invest if you believe in the technology and you want to be a part of the community that's why i think you should invest that's why i invest in anything that's why i invest in my friendships that's why i invest in you guys um that's why i invest in just um you know um certain cryptocurrencies like file coin i really believe in file coin and that's why two more questions pranav asked do you believe in the kyc that the central government enforces does this violate the core principle of bitcoin being decentralized you know when i first wrote the book i thought forget the government we are going to completely disregard the government but the reality is that in many cases the government enables technology the government enables innovations and so i believe we need to work with governments to invent and improve the future of money banks will use cryptocurrencies they already are and the government should use cryptocurrency to enable online voting using the secure blockchain and the immutable blockchain and you know the thing is all of these senators they don't know anything about technology like what is facebook what is all of this no they will become old and die of covid we are a new generation and we will um completely make everything technology related if i was ever president we would never have a tech support problem again but that's a different thing number three last question tiago rajan asks tesla has a superpower to mine you talk about the computational facility for bitcoin mining tesla does not have the superpower to mine i am adding that functionality but tesla is going to have an app store soon and you can bet somebody is going to create a bitcoin app for the tesla so tesla's not going anywhere by the way tesla is the future of sustainable energy it's the future of transportation it's the future of vehicles and literally every time i see another tesla driver on the road i'm like yo and he's like yo or she so it's almost like a community so all right let's see what the answer was let's see drum roll please finish and reveal okay yes i'm so glad that most of you got that answer i didn't even talk about proof of work you know what that means is that you guys did your homework you guys did your homework that's exactly that's exactly what it was so good job really um appreciate that all right so um that was that first question so now good job guys if you got that you're you're amazing you're my hero now what we're going to do is we're going to start building so the first thing we want to do when we start building is we want to open up command prompt so let's see we'll open up command prompt and we will make sure that everything is a-ok on the command prompt so um so let's make a directory here i keep thinking this is linux so this is like um make dirt does that work on windows i always forget it's like um what was the command let's just do like um hondur like cd into the documents folder and let's just like cd into pictures why not um and then i'm getting it and then get clone we'll not even get in it let's just do like um let's just create a node app so hold on we'll just create a node app and um where's that node app at in order to create a node app we have to start with some code right so before we do anything we need the code for the node app and how do i generally start for node apps what i generally do when i'm like building node apps is like um you start off with like this boilerplate code where where um you just basically have it run on 127.0.0 and that's really it's only like a few lines of code really and you can just basically find that somewhere like basic node app um let me make sure it's like there it is okay let me also show you what i'm looking at right now so you can see what i'm looking at right now is the um that's fine whatever let's start here okay um the node app here we go oh my god there we go and we want that to be in uh javascript right that's what the language is and we want that to be a little smaller like control yeah just like that okay okay so this is like the basics of a node app you literally just have you literally just have um this like very basic script and all this does is create a node a server that's a javascript server so we want to add things to this thing you know this is not enough for us it is not enough at all so in order to fix that in order to fix that we're going to have to do some interesting things the first thing we're going to have to do is we're going to write some functions so what are the functions that we want to write what are the what are the most relevant functions for us in this so the first thing we want to do is we want to have a we want to have a function that converts our bitcoin to visa and let me talk about why we want to do that in a second but let's just write out the functions we need first so we need a couple functions a couple helper functions to do a couple of things for us the first function is going to be able to convert bitcoin to visa like a like an actual debit card that we can spend on electricity the other function is going to record our earnings to the blockchain via a smart contract so we're gonna have that function as well so record earnings we want another function that's going to be able to train an ai so this ai is going to be able to reinvest for us we'll call it train agent and do we need any other functions i mean that's quite a lot of functions already we do actually the the last function we need is an invest function so the invest function will very intelligently reinvest the mined earnings into a series of alt coins and that's how that works we got bitcoin to v cell we have our record earnings oh we have one more from function what do i think where are we going to get the data it all starts with the data it's not just going to you know invest using nothing it's going to invest using smart data so we have a data stream that we are going to be constantly pulling from okay so those are our functions and we're going to talk about each of these in order you know i like to write out my functions before even getting to like the details of the logic right so what that means is that in the header so like right when the right when the app starts it's going to immediately start training this agent right so train agent is going to do all that logic and so we call that right up there and so but in train agent what do we want to do well in train agent we want to do a couple of things first we want to get that data stream so we're just going to run that data stream function once we collect that data stream data stream we're going to um we're going to con convert like let's say you know every set intervals let's say every 24 hours so i have an if statements like if 24 hour mark has passed run these three functions number one um but even before that we have this like training code like all the machine learning code is happening right there right and um so uh if the 24 hour mark has passed uh convert the bitcoin to visa to pay for electricity pay for electricity electricity and then invest the rest invest the other earnings and uh once you've done that record everything that you've done for the day record to the blockchain to the b chain to the blockchain okay so invest in let's say invest in two altcoin and two all coins okay so that's basically the logic right here like we haven't actually implemented any of the details but that's kind of like the general hierarchy of like we have this node app right so this is we have this node.js app and it starts right here and in about 30 39 lines of code i think you can see the the general gist of what we're trying to build here we're creating a node app that runs on the m1 and this node app it's going to right when it starts start training an ai agent and that is going to call this train agent function we're going to continuously be pulling all of these cryptocurrency price data from let's say kraken which is one of the major uh cryptocurrency exchanges cryptocurrency price data let's say the top top 30 alt coins every single day all the price trends maybe like eight different features like it's high it's low everything that's um um all of that stuff right so the cryptocurrency price data the top 30 alt coins we're getting from this data stream we're going to use that to train this ai so we have some reinforcement learning happening here some reinforcement learning and we have this model like a weight matrix that's learned what to do with the weight matrix we take weight matrix and we um used to forecast investments gasp automated investing every 24 hours and then we convert it to visa visa just to pay for electricity you know if tesla accepted bitcoin then we would not need to do this step but they don't and so we have to work with the existing financial system um to do that and then we invest the rest via um basically a bitcoin wallet and then we record the earnings to the blockchain via a smart contract and that's going to be a really exciting part we can even write smart contracts with javascript bitcoin scripting language is amazing guys i know it's limited you know satoshi limited it on purpose but it is an amazing scripting language and i think it doesn't get enough love because of ethereum's touring completeness um but i have you know plenty of videos on just search like decentralized applications suraj on youtube for like the greatest greatest hits of all of these uh just amazing stuff so let's build this what are our dependencies that's the next step what do we need for this you know like there's a lot of functionality that we're asking this small little node app to do so we need to know what those dependencies are going to be well what do we need well first of all if this is going to be a node app then we need to use node right and so this is the http this is the requirement for node right here to access the web and uh what else do we need well if we're gonna be sending bitcoin and all coins and crypto currencies all over the place we need a package that lets us do that very easily well i've got a great one it's called constant crypto account it's called um send crypto and this is just an npm node package that somebody made and that abstracts away a lot of the difficulty for us we can use the wrapper that they created to do this very quickly and what else do we need well every 24 hours we want to reinvest our savings so we're going to need a timer of some kind to be able to know when to invest and then lastly what else do we need that's really it oh we need um how are we going to uh save some of the crypto for ourselves well i personally use coinbase because um i will say i'm a little biased because brian armstrong the ceo of coinbase is my friend so i know some people don't like coinbase because they think it's a bank but um i can tell you that brian is a great human being and he has an amazing vision for creating an open financial system for the world and i very much support coinbase i don't care what anyone says i think they're a great company and they've done a lot of good for the world and they've helped people who are not banked become banked in developing countries and that is just one of the most powerful things you can do for anybody anybody in this community can attest to that i'm sure the bitcoin awards has changed at least hopefully some people's lives at this point and so what do we need to we need to use uh coinbase so we're gonna say let's require the coinbase uh javascript sdk to save bitcoin to my coinbase account and to do a bunch of other things so those are the four dependencies that's the general gist and now we can start looking at some of these things like what are we going to do with this we're going to do that before we get to that let me also show you the minor that i chose to use on the m1 right you need to see what like there's so many different like bitcoin miners out there why did i choose this one are they paying me what's my you know what's my angle with this one let's talk about all that so um first things first uh this miner is called honeyminer and they are not paying me or sponsoring this i just thought that this was the easiest way to mine on a mac that did not require a lot of you know installation and too many steps it's basically a graphical user interface you don't have to be able to code to do this you literally just start download this app it's available for windows and mac and you can use whatever miner you want this is what i personally use because it's so easy and you know is it the most efficient maybe not um you can calculate your earnings with this thing of you know how much am i going to make you know it's a lot of dough over time and that's not even taking taking into account appreciation and how the value of the dollar is falling every day because people are realizing that um you know in god we trust is just not a good trustworthy thing god is not real you know god is us we are god human potential is god we are in a simulation and we are slowly realizing that collectively as we become more and more powerful and interconnected as the nervous system of humanity the internet is uh becomes more and more robust in its ability to communicate and spread ideas so this is honeyminer and this is why you can download honeyminer and just start literally you just download it and just hit mine and it will find your cpu it will find your gpu it will optimally use those to start mining bitcoin and using your computing power to start mining bitcoin but then and so you have a bitcoin address that it's going to generate for you and that is the address that we're going to use in the node web app right we can say like okay all the mined bitcoins from this address let's start sending money all over the place using javascript and so that's the basic idea all right so um let's get back to coding but before we get to coding i have the second question for you so i hope you're ready for the second question we're about to start it up so the second question is hmm what is the second question the second question is you guys answer so fast by the way this some of you answered so fast this one person that was really fast you gotta gotta appreciate that the second question is why does bitcoin use sha256 to generate public private key pairs is it a it doesn't matter it's it's arbitrary they could use any algorithm why shot 256 is it b tupac is still alive is it c it uses the least amount of computation or is it d it's a one-way hash function of those is the correct answer let's see who gets that one you know i will be very proud of whoever gets that one and um i think that wow someone might actually not get this so um we'll talk about this guys we'll talk about this one two questions i'll answer while you guys answer this number one muhammad asks basically we're getting a reward right after solving the equation true so my question is can we link ai to increase efficiency muhammad we have been working on a web app to replace item pool and just like automate like the rewards and um it's just you know at scale it gets kind of buggy and you know how it is like always before the demo it doesn't work and so like every friday we're like all right it's going to work this time and then it doesn't so um you know my patience is running out in terms of it not working so i really hope it works next week but just know that i i'm constantly working to improve this experience for you guys like this is so much fun for me and i hope it's fun for you second and last question for this uh round um as terex asks bro can you explain zero knowledge proofs now zero knowledge proofs are um not a trivial thing to explain but i guess i am good at explaining complex topics and making them approachable zero knowledge proofs are like z cash is an example of a zero knowledge proof based cryptocurrency um i think monero as well the fully anonymous cryptocurrency is an example of using zero knowledge proofs vitalik buterin the inventor of ethereum has some amazing blog posts that explain zero knowledge proofs um basically basically the idea is that how can we mathematically create a framework that allows two parties to be able to interact with as little trust as possible and that basically just increases efficiency and robustness of any um system that involves multiple participants and zero knowledge proofs are basically a way to do that it's almost like you know you you think there's no free lunch you know the no free lunch theorem like you have to give away some knowledge about yourself no you don't you there's a way to do it and be completely anonymous you know the answers for this one are not making me happy i i think i might have might have not uh explained this one properly but we're going to talk about this we're going to talk about this one okay so let me reveal the answer to this in 10 seconds all right 10 eight seven six five four three two one i'm gonna reveal it now here we go oh wow okay so i guess i guess most of you did get that okay i was wrong good job all right wow i thought it was a i thought everybody was choosing it doesn't matter it's arbitrary but it turns out that you guys chose the right one which really impresses me a lot that you guys know that so great work i i really appreciate you getting that one correctly so all right good job with that let's continue going and we'll get right back into this uh code base all right the code to the code base we go all righty okay here we go three two one boom okay so where were we with this tesla with this uh code base thing so we were at a point where we were just um building something we were building something what was that something we were building um btc to visa right let's talk about that btc to visa function so um if we have a private key it's okay so if we have a private key so let's say it's a constant it's not going to change constant private key and let's say it's like in this environments file so it's not we don't put it directly in our code that's just for safety's sake but let's say it's in the separate environments file it's called private key so we know what it is and we have an account um using this crypto account this is basically our bitcoin private key right this is our bitcoin private key and um for now i do not have a tesla tattoo but but um no i wouldn't do that i don't think i would do that that'd be a little crazy but i i you know it's not too crazy but i you know when i got like my second tat the guy was like you're gonna be like me one day you're gonna have tats all over your body no i'm just gonna have two tattoos i don't i don't need any more i'm good two is enough for me i'm not gonna be like all tatted over with like face tats and all that stuff it's not gonna happen but all right so let's say we have a bitcoin private key you know this is this is basically the private key from the honeyminer right so we have honeyminder running we go into that gui we pull out that private key we paste it in here right so that's how it works and um now what we're going to have to do is asynchronously this is the async function because we're going to make a call to the web and we don't want to block the ui thread or the terminal thread while that request is being made so we'll do it asynchronously so one doesn't have to wait for the other and um we will now um send money so so simple to send money we can say here's a transaction hash which is the output of our account sending uh money to this let's say it's a test address this is let's this is actually my coinbase address but we're going to put test and how much are we going to send we're going to send 0.01 bitcoin 0.01 what we're going to send 0.01 bitcoin to to that address with that transaction hash and then on confirmation we're gonna like print something out like yep successfully successfully sent something like that and that's how that works isn't that crazy so we need to close this up as well so that's all happening in the async function so basically just using bit this is basically like a bitcoin wallet and we could just send money um you know every x hours every x hours to uh you know my coinbase account just for personal like savings and so that's the first part let's get to the second part now so that's that's the bitcoin to visa part you know we're training this agent and you know inside of the training agent fund oh we need the data right we did the btc to visa we didn't write out the data stream part so what does the data stream part look like you know in all you know we're about to do some machine learning so we got to start with the data give me that data so what do we do with the data so i'm just going to write out this one liner basically of how to do this if we have a ticker um if we have a ticker what's the ticker the ticker ticker ticker um oh yeah there's one more dependency we need it's called ticker it's called crypto ticker and so you can find it on npm it's called crypto ticker and you do npm install and then once you do npm install in terminal you can call that ticker function and you can say using kraken which is one of the major um cryptocurrency exchanges check the price of ltc to usd and then once you've done that asynchronously it's like built in the async he like built in the he or she built in the async function into this um script and uh print out print out like all that data all that value and then if there's an error then catch that error by uh printing it out okay and so that's just for one that's just for one price value but we can do the same for like let's say eth to usd and then we could do the same for say um you know what's the third all coin we want to invest in let's say ltc btc um fil to usd let's say and so that's what it's going to do so this data stream so we're going to call this constantly and it's just going to constantly be sending us this data and we want to build a data set using these prices to train our reinforcement learning algorithm on and so that's our data stream and uh so that's our data stream what is next oh where's this invest function that's that's also going to write out this invest function so what does the invest function look like well i'm going to take us on a little journey to the coinbase documentation coinbase documentation node let's say it's called node and so in the api reference i'll be able to show you some really interesting things right now i think you're going to like this so check this out this is coin base is api and so coinbase's api is right here and we can see all of the things that we can do with the api we can make requests to your account make deposits from your account and one of my favorite things about this is that it also has like built-in codes so like we can see what the node version of everything looks like if we um go to like accounts and then we just see what all the api calls are somewhere it's like you can switch it to node or like ruby or like whatever language you want brian where are you at bro we gotta fix this where's the note thing okay so it's there somewhere but like so this is the this is a document this is what i was reading in terms of uh in terms of building this so that's that and so now let's let's let's code this out so uh in terms of investing i'm just gonna paste this in actually investing from my github repo okay let's take a look at this so when it comes to investing we're gonna say okay what's the best altcoin okay we're gonna give this the best altcoin as a parameter because the reinforcement learning agent is going to want to know is going to tell us what the best all coin is then we're going to use this invest function to invest in that best altcoin all right so best all coin and so then we initialize the coinbase client i think we already did that up up there so we don't have to say it again but we have that all coin and then we connect it to it using our you know key and secret and then we get our account and then we can buy some bitcoin so using the money we've earned locally mining we could send that to coinbase and then from coinbase we can do whatever we need in terms of investing in other cryptocurrencies very easily right so that's one of the utilities of a centralized service is that um it helps you transfer between different state and network currencies and just all types of currencies so always be a need for some type of trust like trust will never go away if you want to see the most beautiful video i've ever made on bitcoin watch the trust that binds just search the trust that binds siraj you you might even cry at the end it's like this seven minute video on trust and human connection and bitcoin and everything you know what it is so function invest in the best all coin that's what that will do and i think we basically wrote all of our functions here except for the main part the train agent oh and record earnings so for record earnings um that part is a smart contract i just wanted to do that for like the decentralized autonomous part that's not necessary we could record the earnings to like a local notebook but i just for the sake of like you know scripting i wanted to i wanted to show you guys what like you know that would look like it and uh basically i gotta show you the smart contract that i found for that this is like a newer thing it didn't exist like three four years ago and so what is that it's called bitcoin computer smart contracts in javascript look at this beautiful fresh repository by clemenslay and slash rm this is a javascript library for running smart contracts on bitcoin okay and so bitcoin has its own scripting language we can send programs to live on the bitcoin blockchain that is shared by all the miners by all the nodes in the network and it's replicated across all of them now you might be thinking well won't the blockchain get super big if i put like an entire operating system on it yes it will theoretically you couldn't even do that because you have to it you can't even have a for loop in the bitcoin scripting language you it's so it's such a limited language but that's for security reasons but you know there are ways around that you know there are things you can do you can create your own token based on bitcoin um you don't necessarily need erc20 with ethereum to do that although that's the most popular way um we can create a chat app that is sending messages back and forth across the blockchain so i can say hello world it's going to be saved into the blockchain and it will literally never go away it's like a marriage contract it's like a legal contract it's like whatever type of contract it's like it will never go away unless the blockchain itself dies and the blockchain will never die the blockchain is like divine in that way it's just mathematically encrypted in encryption we trust right so that's the idea and so very very easy to use this like all we have to do to write a smart contract is basically create it and then run it on the test network like look at that in that few lines of code we can run a smart contract so the smart contract we want to write is just basically time stamping the trades we made for the day and how much we invested and we're putting that on the blockchain so just because we want to make this as autonomous as possible someday there is no server involved at all and everything is happening through the blockchain but we're not quite there yet so let's get back to the code and put that in there and so we'll go right to that where was that record earnings no yeah exactly and we'll put this uh dependency up not here we'll put it up and all right so we have a record smart contract replace the seed with some seed text you know like hello mary had a little lamb or something had a little lamb had a little bit and um mary had a little bitcoin which chain uh this is the main bitcoin chain or else it's bitcoin cash not testnet mainnet the main network and this is just a counter right now it's just counting things to bitcoin what do we want that counter to be let's say that it's going to be um some amount that we in amount invested and then that's what we're going to just push to the blockchain amount invested okay okay so that's that that'll everything and so train agent okay here we go train agent here we go what is what are we going to do for train agent well for train agent for that part what i want to do is i want to use reinforce dot reinforce.js guys i'm the number five most followed developer on github check this out you're never gonna believe this out of 45 million developers that's insane let's see like 30k i think it's like that what a weird metric let's see number one will always be linus torvalds the king made linux made github but number oh number nine here i am there i am sir roger vol boom only linus torvalds is beating me but he can always beat me i i applaud linus to our volts where were we stop flexing get back to work all right okay reinforce js okay so this is like the javascript library for reinforcement learning i know everybody loves reinforcement learning um it's super cool and this is basically a way to do that and so we have an option of which algorithm we want to use uh to smartly predict what the price of bitcoin is going to be and so we're just going to pick the easiest one deep q learning um because uh this dqn solver because it's just super easy so that's the one we're going to use um so that's one we're going to use we will save that import that and that's what we're going to use for our reinforcement learning agent let's go back to that and yeah you know i think that reinforcement learning is very much underappreciated when it comes to just things in production i think supervised learning is just used way more often but reinforcement learning is just so cool right i mean it's it's it's not just some gimmick it's like the real deal so we have this dqn solver and in the dqn solver we want to add a bunch of things we want to add train agent code we're going to say so we have we have the hyper parameters which are set by the qn opt and let's just add a single hyper parameter in terms of set epsilon set set alpha like the learning rate or something to 0.5 you know this could be any number of things we can even learn what those should be and then we can have a solver that is basically the deep q learner agent using an environment using and using those hyper parameters and we have a state matrix which is going to be empty we have a action which is going to be whatever the dqn solver decides to do using the state and then we lastly we have some reward that we're going to give each of these investments and it will just learn it will learn from all of those rewards to be able to predict what the best prices would be and so then we can even do dqn.solver.predict based on you know one of x options what is the best all coin prediction to have and that's what we're going to send to well not all coin best all coin right best all coin and that's the general idea and so da da da da da obviously we need to add like way more hyper parameters to this thing uh if we want it to be any sort of accurate but i'll just paste that in there and then okay so that's that now i have my third question for you i know you guys are waiting for the third one and you got some really cool questions and i'm excited to answer them so here we go okay um [Music] what's my last question for you here's my last question for you my last question is i got a hard one this is not an easy question guys uh oh uh oh okay so this equation it's very popular it's used a lot it's used a lot in reinforcement learning you use all over the place and um which popular equation is this is it a the state function is it b the value function is it c the bellman equation or is it d deep deterministic policy gradients that's the question i'm so glad that there's a very evenly distributed set of answers it means that this was a sufficiently hard question for the general skill level of this audience which is good now eventually i want to create personalized curriculums for each of you and just be tracking all of your learnings individually and really help you level up to the next level but that's the that's the deal with code royale i'm super excited about that um all right i'm going to answer two questions number one um lurk asks i'm a beginner programmer and i'm still clueless about learning programming do you think books are the best way listen lurk um i do not think books are the best way and i feel very strongly about this you know many programmers are going to say books of the way but i just don't have time to learn like that i hated columbia university i hated being in a classroom with the professor and having to stay awake for an hour while they just you know lectured on and on about you know whatever things there was no interactivity this is you know one of my attempts at making this more fun but the next level of education is gaming and so i want code royale to be the most fun and engaging way for beginners to learn machine learning that's the goal and i will work every single day of 2021 to make that happen and so but i can't i can't recommend that game to you because it's not out yet so in the meantime the best way for a beginner to learn programming and to learn machine learning would be to just start building something that you want to build just hack your way into it just be like okay i want to build a time machine not a time machine but like i want to build a i want to build a bitcoin miner i want to build a um housing price prediction algorithm i want to build a robot whatever it is just be like that's my project and just be determined to do that give yourself some set amount of time and just say i will figure this out and just constantly be like looking up on stack overflow on github on reddit on everything to curate the exact set of learning resources that you need to learn that thing and nothing more right you want to be super efficient about your time learning as i am i do not waste time learning things i don't need to i focus on what i need to learn because my time is valuable and so is yours so books are not necessarily the best way to learn blog posts i love blog posts videos of course i love videos and games but that's that's the future we're talking about the present games are gonna happen you know so second question related asks how could this be possible like as far as i know asic miners aren't even very profitable right now related title is correct this is not profitable i don't know if i said that in the beginning this is just a proof of concept to show that what a decentralized autonomous system looks like my car is a decentralized app at this point because it's using bitcoin in a way i mean there's various definitions of that but no it's not profitable um it's using that m1 which is like a cpu gpu mix um asics are going to be more profitable the most profitable type of uh processor you could use for bitcoin mining as of today and even then it's not that profitable but you know profitable is a word that is weighted by how valuable it is today you know if bitcoin hits one million dollars tomorrow then of course it's gonna be profitable right but nobody knows that so if you really want to maximize your efficiency and time and money get an asic don't use an m1 like i did this was just for fun and uh yeah that just just you know there's one on amazon actually i would have bought it for this but like it takes more than a week to arrive but there's like a usb powered asic that you could buy on amazon second and last question um and yeah i'll show the answers at the end related ba asks how can you start building if you don't open a book and learn the basics in a structured way great great question great question so you know i like to think of this as like there exists this mental model of everything right there's a mental model of how to be a great pilot and this pilot has spent many years building that mental model and now he's got that right there exists a mental model of machine learning that the greatest machine learning engineers and researchers in the world already have and how do we get that mental model it's just basically how is the fastest way we can do that books are a way to do that of course but they are the traditional way to do that you know there's actually a great book if you if you're determined on reading a book i would the one i would recommend is called the 100 page machine learning book i'll say it again the 100 page machine learning book it's a free book and you can find it online and that's a great way if you if you want to read a book it's short it's sweet it's to the point and so not all books are the devil in terms of like wasting your time like textbooks some are like very efficient and short and so i'm a fan of those and um you know i create my own structure i've always been like this i i hate it when someone is like you need to learn this way and that that that's just how i am i like to learn however i want like whatever you think education is i don't believe that i have my own definition of education and i will impose that on reality because it's just better i know it's better i really believe that so um you know reddit blog posts are great if you just like search reddit like how to learn programming as fast as possible and then just go to the top comments reddit is probably the best um structured knowledge database on earth that is accessible to everybody and that is because of the upvote system which essentially creates a structure for us um if you look on my github i have a bunch of machine learning curriculums i've created just like the top repositories basically just curating content for everybody but um what else is a great resource fast.ai and um yeah learn by doing right learn by building learn by building and that's that's just the future we're getting into there are going to be people at universities who've invested seven years and a lot of money into their phds and all this and so you need to do exactly what i did that's the only way to learn it's not true it's not true remember you can learn anything using the internet the internet is my university and uh you know part of me i'm glad that universities are not you know succeeding because they're just not adaptable to a changing world and but the internet is the internet will be here it will only improve over time while universities will slowly um crumble and uh so let's see what the answer is finish and reveal wow okay see this was a really great question for you guys i'm gonna really turn up the math in the next live stream because uh a good number of people did not get this one correct but a really good number did um 24 people got that correctly which i love to see so let's now see um let's now announce the winners so let me view the results and i want to show everybody who the winners are as related asked for so i'm going to pull that up right now let's see who the winners are i'm going to pick these not arbitrarily but just in terms of top down okay so who do we have here winner number one is ilia n ilia n got all three of them correct good job okay maria didn't get that mark mark is the next one and online marty online marty these are the three people that got that win today it's ilya n ilia n mark and online marty congrats to the three of you everybody congratulate them in the chat guys email me hello at roger vault in the next hour with your bitcoin address and i'll send it to you within five hours you know the deal and you have an hour to do that all right congratulations mark congratulations ilya and congratulations online marty the three of you got all of them correctly and i'm very proud of you what i'm going to do now is i'm going to end this live stream with the freestyle rap about bitcoin here we go all right three two one where's that where the music get where's it at [Music] i had bitcoin dreams they told me that i was free i rock block chains on them stock chains [Music] i rock block chains playing all the stock games it's a purple ledger with no central ah open source protocol facts miners carry shi256 on their backs they be generating 21 million coins make it rain bitcoin every day free to join everybody does it yeah actually those were lines from my old bitcoin but i just want to see him again [Music] making safegrain i'm on my nx junction the junction between these two different equations i got my nsr that's the ios equation i do it without any platform blockchain's immutable it's at horn all right yo okay guys i love you so much thank you for being here today um congratulations to our winners again online marty uh ilya and uh mark and i love you guys thank you for being here i will see you this time next week play code royale is coming out by the end of the month let me say it publicly it's so scary to say that but it's coming out before the month ends you guys will hold me to that and go sign up at the website play code royale.com if you haven't yet those that signed up on the waitlist will get first access and everybody else will um hopefully be jealous of them and want access and we'll make it super exclusive and the game will be successful and it's going to be awesome it's going to be the greatest um thing ever i'm super excited so thank you guys i love you and have a great evening have a great morning wherever you are in the world and

Original Description

Bitcoin just hit an all time high of $33K today. In order to celebrate, lets see if we can install a bitcoin mining client onto my Tesla’s hardware. I don’t know if this is actually possible, but it’s worth it for the educational aspect. Tesla’s are computers on wheels, think of them like you would any other personal computer, except this one is attached to an electric drive train. The vision I have is that someday I can let my Tesla act as a fully autonomous robo-taxi that'll also be earning bitcoin the whole time! It will use its earnings, from both transportation services and bitcoin mining services to pay for its own expenses (repairs, electricity costs, and upgrades) as well as invest them into a diversified portfolio of emerging crypto-community networks. In this episode of my weekly live stream, we’re going to learn a lot about how Bitcoin works, how to install a Bitcoin mining client, and how to create an autonomous trading bot on that same hardware. 3 Wizards will each win $50 BTC for answering my 3 questions related to Bitcoin. Start studying Bitcoin’s functionality and I’ll see you then! Sign up here to answer live questions and compete for the cash prize pool this week: https://itempool.com/llsourcell/live Code for this episode: https://github.com/llsourcell/tesla_bitcoin_miner Signup for Code Royale to get notified of release on PC/Mac/iOS/Android on Feb 1! It will be the most enjoyable, free to play, beginner friendly way to learn Machine Learning: www.playcoderoyale.com This week's live game study curriculum: ---------------------------------------------------------------------- Watch the 1st Youtube Video I ever made!! (What is Bitcoin?): https://www.youtube.com/watch?v=nVFDZsxOMRg Watch How to Build a Bitcoin Startup: https://www.youtube.com/watch?v=w81Z8JHARTk Watch my interview with my friend Bryan Armstrong (CEO coinbase): https://www.youtube.com/watch?v=grNU_svKs3o Watch how Blockchain works: https://www.youtube.com/watch?v=LZEHOlZY2To
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Siraj Raval · Siraj Raval · 0 of 60

← Previous Next →
1 What is Bitcoin?
What is Bitcoin?
Siraj Raval
2 5 Ways to Use Bitcoin
5 Ways to Use Bitcoin
Siraj Raval
3 BTC Fever - Siraj [Music Video]
BTC Fever - Siraj [Music Video]
Siraj Raval
4 5 Reasons to Build Decentralized Apps
5 Reasons to Build Decentralized Apps
Siraj Raval
5 The Interplanetary File System
The Interplanetary File System
Siraj Raval
6 How to Build a Dapp in 3 min
How to Build a Dapp in 3 min
Siraj Raval
7 Life Before Smartphones
Life Before Smartphones
Siraj Raval
8 4 Ways to Use Smart Contracts
4 Ways to Use Smart Contracts
Siraj Raval
9 3 Dapps You HAVE to See
3 Dapps You HAVE to See
Siraj Raval
10 Char's Life as a BitTorrent Engineer
Char's Life as a BitTorrent Engineer
Siraj Raval
11 4 Reasons AlphaGo is a Huge Deal
4 Reasons AlphaGo is a Huge Deal
Siraj Raval
12 Build a Neural Net in 4 Minutes
Build a Neural Net in 4 Minutes
Siraj Raval
13 Sentiment Analysis in 4 Minutes
Sentiment Analysis in 4 Minutes
Siraj Raval
14 The Hackathon Life
The Hackathon Life
Siraj Raval
15 Your First ML App - Machine Learning for Hackers #1
Your First ML App - Machine Learning for Hackers #1
Siraj Raval
16 Build an AI Composer - Machine Learning for Hackers #2
Build an AI Composer - Machine Learning for Hackers #2
Siraj Raval
17 Build a Game AI - Machine Learning for Hackers #3
Build a Game AI - Machine Learning for Hackers #3
Siraj Raval
18 Build a Movie Recommender - Machine Learning for Hackers #4
Build a Movie Recommender - Machine Learning for Hackers #4
Siraj Raval
19 Build an AI Artist - Machine Learning for Hackers #5
Build an AI Artist - Machine Learning for Hackers #5
Siraj Raval
20 Build a Chatbot - ML for Hackers #6
Build a Chatbot - ML for Hackers #6
Siraj Raval
21 Build an AI Reader - Machine Learning for Hackers #7
Build an AI Reader - Machine Learning for Hackers #7
Siraj Raval
22 Build an AI Writer - Machine Learning for Hackers #8
Build an AI Writer - Machine Learning for Hackers #8
Siraj Raval
23 Build a Chatbot w/ an API - ML for Hackers #9
Build a Chatbot w/ an API - ML for Hackers #9
Siraj Raval
24 One-Shot Learning - Fresh Machine Learning #1
One-Shot Learning - Fresh Machine Learning #1
Siraj Raval
25 Generative Adversarial Nets - Fresh Machine Learning #2
Generative Adversarial Nets - Fresh Machine Learning #2
Siraj Raval
26 Tone Analysis - Fresh Machine Learning #3
Tone Analysis - Fresh Machine Learning #3
Siraj Raval
27 Generate Rap Lyrics - Fresh Machine Learning #4
Generate Rap Lyrics - Fresh Machine Learning #4
Siraj Raval
28 Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Siraj Raval
29 Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Siraj Raval
30 Build an Antivirus in 5 Min - Fresh Machine Learning #7
Build an Antivirus in 5 Min - Fresh Machine Learning #7
Siraj Raval
31 TensorFlow in 5 Minutes (tutorial)
TensorFlow in 5 Minutes (tutorial)
Siraj Raval
32 Build a Recurrent Neural Net in 5 Min
Build a Recurrent Neural Net in 5 Min
Siraj Raval
33 Build a Simulation in 5 Min
Build a Simulation in 5 Min
Siraj Raval
34 Build a TensorFlow Image Classifier in 5 Min
Build a TensorFlow Image Classifier in 5 Min
Siraj Raval
35 Tensorboard Explained in 5 Min
Tensorboard Explained in 5 Min
Siraj Raval
36 Generate Music in TensorFlow
Generate Music in TensorFlow
Siraj Raval
37 Build a Game Bot (LIVE)
Build a Game Bot (LIVE)
Siraj Raval
38 Deep Learning Frameworks Compared
Deep Learning Frameworks Compared
Siraj Raval
39 Introduction - Learn Python for Data Science #1
Introduction - Learn Python for Data Science #1
Siraj Raval
40 Build a Neural Network (LIVE)
Build a Neural Network (LIVE)
Siraj Raval
41 Twitter Sentiment Analysis - Learn Python for Data Science #2
Twitter Sentiment Analysis - Learn Python for Data Science #2
Siraj Raval
42 Recommendation Systems - Learn Python for Data Science #3
Recommendation Systems - Learn Python for Data Science #3
Siraj Raval
43 Predicting Stock Prices - Learn Python for Data Science #4
Predicting Stock Prices - Learn Python for Data Science #4
Siraj Raval
44 Pong Neural Network (LIVE)
Pong Neural Network (LIVE)
Siraj Raval
45 Deep Dream in TensorFlow - Learn Python for Data Science #5
Deep Dream in TensorFlow - Learn Python for Data Science #5
Siraj Raval
46 Visualizing Data with D3.js (LIVE)
Visualizing Data with D3.js (LIVE)
Siraj Raval
47 Genetic Algorithms - Learn Python for Data Science #6
Genetic Algorithms - Learn Python for Data Science #6
Siraj Raval
48 Enter Siraj [Music Video]
Enter Siraj [Music Video]
Siraj Raval
49 Build a Web Scraper (LIVE)
Build a Web Scraper (LIVE)
Siraj Raval
50 Why is P vs NP Important?
Why is P vs NP Important?
Siraj Raval
51 How to Make a Neural Network (LIVE)
How to Make a Neural Network (LIVE)
Siraj Raval
52 How to Make an Amazing Tensorflow Chatbot Easily
How to Make an Amazing Tensorflow Chatbot Easily
Siraj Raval
53 How to Make an Amazing Video Game Bot Easily
How to Make an Amazing Video Game Bot Easily
Siraj Raval
54 How to Make a Tensorflow Neural Network (LIVE)
How to Make a Tensorflow Neural Network (LIVE)
Siraj Raval
55 How to Make a Simple Tensorflow Speech Recognizer
How to Make a Simple Tensorflow Speech Recognizer
Siraj Raval
56 Joel Shor - Really Quick Questions with an Awesome Google Engineer
Joel Shor - Really Quick Questions with an Awesome Google Engineer
Siraj Raval
57 How to Make a Path Planning Algorithm Easily (LIVE)
How to Make a Path Planning Algorithm Easily (LIVE)
Siraj Raval
58 The Best Way to Prepare a Dataset Easily
The Best Way to Prepare a Dataset Easily
Siraj Raval
59 Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Siraj Raval
60 How to Make a Tic Tac Toe Neural Network Easily (LIVE)
How to Make a Tic Tac Toe Neural Network Easily (LIVE)
Siraj Raval

This video teaches how to install a bitcoin mining client onto a Tesla's hardware and explores concepts like decentralized technology, artificial intelligence, and reinforcement learning. It covers the use of smart contracts, blockchain, and cryptocurrency trading, and provides a comprehensive overview of the tools and techniques used in the process.

Key Takeaways
  1. Build a Node.js web app for bitcoin mining
  2. Connect the Node.js web app to the M1 Mac Mini
  3. Use reinforcement learning to pick altcoins to invest in
  4. Reinvest mined Bitcoins in personal account, altcoins, and pay for electricity
  5. Use smart contracts to record earnings to the blockchain
  6. Train an AI agent to forecast investments every 24 hours
💡 The video demonstrates how to use a Tesla's hardware to mine bitcoin and explores the potential of decentralized autonomous systems for cryptocurrency trading.

Related Reads

📰
The AI Interview Survival Kit 2026:
Learn the most common AI interview questions for QA and Automation Engineers and how to answer them to increase your chances of acing the interview
Dev.to · Himanshu Agarwal
📰
We put adversarial agent testing directly in Claude Code and Cursor
Learn how to test AI agents using adversarial testing directly in Claude Code and Cursor, streamlining your development process
Dev.to · Sofia Aliferi
📰
The Agentic OS: Apple's AI Strategy for Enterprise Platform Teams
Learn how Apple's Agentic OS embodies a local-first AI strategy and its implications for enterprise platform teams
Dev.to · Omnithium
📰
AI Agent Skill Registry: Stop Prompt Sprawl Before Workflows Break
Learn to design an AI agent skill registry to prevent prompt sprawl and workflow breakdowns
Dev.to · Jack M
Up next
6 Agentic AI Projects: Every AI Engineer Needs in 2026
Rajeev Kanth | BEPEC
Watch →