Building a Basic Income Token with Polygon - Siraj Raval
Ethereum Denver·Sun, Oct 9, 2022, 12:00 AM
Transcript
thank you cool awesome hi everybody well it's great to be here today basic income um before i even start with this let me ask people a few questions here um who here can someone explain basic income to me in your own words who wants to who wants to give a try what what is basic income to you it's a loaded term there's a lot of different definitions yes sir i like that very specific definition yes that i jive with um there's a lot of different ways of structuring a basic income like if you look at how the cost of certain goods and services have increased over the past few decades you'll see that housing health care and um what's the third one housing school yes education those just have been skyrocketing but everything else the cost has been dropping so if we wanted to be very specific about it rather than just giving people money we could just give people some share of equity or literally just give them education health care and housing for free but that's a lot that's pretty complicated i think the easiest way to do this and i've been thinking about this for eight years now um and i've been trying to solve it for eight years now on and off like i'm not just like working on it full time but it's it's such a to me it's like the end goal of all of this like i am not in web 3 i am not in blockchain to improve money i'm here to make money irrelevant because if we look at star trek and we look at these sci-fi novels where we live in this world of abundance where automation is doing everything for us it's just generating all the food that we'd ever need clean limitless energy you know how do we get to that society like money is not relevant in that society where you can just get anything you want and there's no scarcity right and that's what we're getting to we're getting to a world of abundance with enough automation and if we have limitless energy and all this stuff but i think we'll get there and basic income is one step on the ladder to get there and so all that is to say that you know a little bit of philosophy here on why why i'm doing this and why i think this is important i want to get to a world where everybody has all their basic needs met and they can not work just to survive they should work because they want to work you know we have such a limited time on earth we shouldn't just be like so many people hate their jobs and i feel like right i feel like if we had a basic income it would definitely decrease human suffering in the world now now let's get to the implementation enough of the philosophy and like you know utopia stuff so how are we going to do this so when we think about basic income there's several ways of structuring this there's one way is let me just you know create a web app and i will um have a server client architecture it's a heroku you know web app node.js and i'm connected to stripe and anybody who wants money i'll just create a pool of you know usd this is like v1 this is before we get to web3 and i have a pool of usd let's say it's 200 bucks and i create a scheme where anybody who signs up as a user is going to then receive you know a penny every day and there's a limit there right because once eventually the money's going to run out well i could ask people to donate money for charity and that's going to keep it going that would work but it would be limited to people who can receive usd people who have bank accounts and ideally to me what a basic income looks like is totally global it is not based on your nation states not based on your zip code where you grow up it is just a global cryptocurrency and in order for that to happen we can't use something like stripe or any of these web to fintech products we have to use something that is inherently distributed decentralized like uh these cryptocurrencies are and so which cryptocurrency to build this is where the tribalism comes in well you know we have number one the king we have bitcoin but um when it comes to bitcoin we can't create something a token that's going to accrue in value as more and more people use it this is not i mean we could with stacks and like some kind of weird side chain atomic swap thing going on we could do something like that but it's still not no one's really done it that's why i mean i'm sure it's possible but nobody's really done it when it comes to like actual tokens that accrue in value and that people actually use um day-to-day like sweatcoin an app that i downloaded that gives you money to walk it's like proof of mobility super cool it's from the uk yeah it's got five stars on the app store swat coin check them out but they're an erc20 token which is built on ethereum as everybody here knows so ethereum would be the solution here to build some kind of basic income token that's we can we can be very specific about um but the problem with ethereum and there is a problem there are two problems actually the problem with ethereum is that it's really expensive to use in terms of gas fees and it can be pretty slow the throughput for transactions is not that good and there's several reasons for this and we know that the core team is working on solutions to this for layer one for the main chain they're working on sharding which is taking a bunch of data splitting it up into several chunks and distributing it across the network in the hopes that throughput increases so sharding we have one there is increasing the block size that's another one there's changing the consensus algorithm from proof of work which is what it currently is the proof of stake all this is great they are doing as much as they possibly can but if you look at vitalik's blog post there is no eth2 without layer two layer two is a part of the eth 2.0 upgrade which is not a one day event it is it happens over time who knows how long that's going to take though that could take forever but you need another layer you need an execution layer in fact i don't know if you guys saw this but they stopped using the terms l1 and l2 like officially now it's the execution layer and the consensus layer and so you can have the execution layer but you need that you can have the consensus layer like the main chain but you need that execution layer and that's what polygon is and that's why i work at polygon so i've been a youtuber for five years full-time my own boss it's been great i've been loving it but i joined polygon because i feel as excited about polygon today as i did about ethereum five or six years ago because in the end i only care about the end result can we create scalable dapps for users and i remember the students in my dapp class five years ago that i hosted on the internet they were building amazing dapps across every industry social networking dapps decentralized uber decentralized airbnb did any of them pick up did any of them gain mass adoption no and why it's because they ran into these problems high gas fees and low and slow throughput and that's what polygon solves as a separate chain right now it is what's called a plasma side chain but polygon has spent over a billion dollars on acquiring every almost every uh reputable zero knowledge roll-up startup so all that talent and technology is there and polygon today there are thousands of dapps that have been deployed to polygon that are scalable and they're you know quick swap uniswap if you go to austinpolygon.com you can see literally thousands of them and the great thing about polygon is that if you are an ethereum developer which i assume everybody here is or wants to be if you are an ethereum developer and you want to make a super scalable really um you know feature-rich app you can just do that forget about polygon just focus on ethereum i've got my truffle library i've got ganache i've got um you know all of the the suite of tools that come with ethereum you can build that um when you don't need anything having to do with polygon you know truffle for smart contracts ganache for a test blockchain drizzle for your front end things like that if you don't want to use that there's hard hat right who here has used hard hat by show of hands okay nice so we got some you know some serious people here so we got hard hat i like hard hat as well you know it's like an alternative to truffle it's pretty cool um in terms of what i get to actually compile and work it's probably more like truffle but like i want hard hat to work but it doesn't it's like it seems like it should be cleaner so all of these tools you can use to build your ethereum dap now to make it run on polygon all you have to do is change a single line of code in your let's say for truffle it'd be truffleconfig.js or in hard hat it would be like i think a command line where you just change the rpc from the ethereum whatever testnet london to the polygon test net which is mumbai okay that's it you're just deploying your ethereum dap to a different chain and then what you do is you let polygon you let polygon do the rest polygons validators the people who are securing the network through staking they will send your transaction data to the ethereum main chain every x interval and so and what polygon is also working on is adding to this send a proof of a validity proof a zero knowledge proof now this is this is in works right now um it's very rnd if you want to get started um building these um zero knowledge proofs on polygon already you can do that um you just have to go to the our latest acquisition which is hermes um scalable payments and you know i've tried looking at this sdk it's still like really hard to use so i wouldn't recommend it we want to take this and like put it into the polygon sdk so it's a little easier in fact the ideal goal is that you don't have to do any of this like this should be just built into the chains all you have to do is build your apps and the features so okay that's the first 10 minutes i've got 10 more so that's me that's enough of me showing polygon let's get to what this basic income smart contract looks like so let's write this out in solidity so we're going to call this basic income eath denver dot solidity great okay so let's just write this out all right this is going to be 80 lines of code and we're going to think about all of the gotchas here and things that we can do better things that we're doing well so first we're going to say what version of solidity we have and i'm going to say it's you know 0.
4.21 probably not the latest but i don't care and then we're going to create our smart contract we're going to call it a basic income token now this token what we want is we want each person to have a token and we don't want a single person to be able to say i'm john but i'm also bob and mary and alice and you know we want one person to receive a token we don't want them to be able to create 30 different accounts and receive that money because that would be cheating the system we need some kind of way to create what's called a proof of unique identity what does that look like and that is the problem that i haven't quite figured out how to do and so many super smart people have been working on this for years and there's like this idea of a decentralized id and you know of all people microsoft you know worked on that um there's this idea of reputation right the longer you've been on the network the more money you can get and the oldest accounts in the network those those are the ones perhaps at some interval after you've been you know a part of the network for say two months then you get the funds unlocked there's a lot of different ways we can do this but let's wait for that super hard problem till the very end to try to solve that so let's just keep building here so we have our token we're going to call it basic income token or bi for short basic income token that works and okay so we have a name for it um we're going to have a supply now for it so how many how many of these do we want well i'm going to say um you know in solidity you want to use um an integer and you want to specify the the byte count so i'm saying eight here so i'm gonna say okay so um how many decimal places do we want we just want zero so we don't we don't want it to be a lot um now how many of them do we want right so if we are making a basic income token for the entire planet and for every human we need some billionaires yeah we need a lot of these tokens right um so i'm gonna say that uh this we're gonna have um i think there's like eight billion humans-ish right so something like that but just to be safe let's say nine billion um because we're planning for the future here like satoshi did 2140 is when the last bitcoin will be mined i think something like that um let's assume so let's you know everything has an expiry date it's not like this is going to be like forever so let's assume we need this until we hit the singularity and like we become superhuman gods so that's probably within 50 to 100 years let's be you know real like within a hundred years we're not going to be these like meat bags like definitely not so um total supply i would say so in a hundred years how many humans will we have will probably have like um let's say 15 billion max so we'll have 15 billion tokens and everybody will get a single token and once you have your token that token is your identity it is your unique 25 character alphanumeric identifier then once you have that token we will send you dividends every day so you're earning money every day using this identifier so the dividends are the actual income the token is the identifier and we have to switch how we think about that i think in this case all right so we have 15 billion so let me just make sure i've got all these zeros here yeah okay 15 million there's their billion great okay and now we have our constructor if you are new to solidity um one thing that got deprecated was naming the constructor the same as your uh smart contract file so we have to just call this constructor instead of calling a basic income token constructor so that's just like a weird thing that changed but as that's how it goes so we have a balance of um we're going to start off with the total supply and we're going to initially assign all of these tokens to the contracts creator we need one place and the creator doesn't have to be a human the creator can be a smart contract it can be a machine we need some place for those tokens to live before they're distributed and so we're going to give it access to the total supply so the initial balance will be the total supply and once we have that we're going to uh fire a transfer function which we haven't written yet where we're going to give every address that signs up in an array so we're going to start at the first address some token from this supply okay and so initially we're going to give the whole supply to this first address so that's going to be the first transfer we're going to keep using this transfer function over and over and over and over again so we have our public function we have our constructor we did what we had to do now let's start writing out some of the more hard functions so we we have the constructor let's let's get to naming some variables that we're going to need later on we're going to need um we're going to need a we're going to we're going to need to know what the balance of the dividend is like how much do we want to give people we know the token supply how much do we want to give people every week because we can give people thousands of tokens a day but what does that equate to in value and see i'm still thinking in terms of usd i'm trying to change that frame if you think about the price of a house um in the past year it has in terms of usd it's gone it's gone up but in terms of bitcoin it's actually gone down so that's a different standard that i need i'm trying to you know re architect my mind around and i think it's a good thing so um we have a balance of and so what what does this how many tokens we want to give as a dividend we're going to say to keep things simple one and just let that accrue over time as as there is some scarce resource that people pay for with this token that gives it the value in this case i would hope that it would be basic necessities like food and housing and health and things like that and we could even architect it so that we are partnering with other web 3 companies that are on chain that offer on-chain housing and on-chain health and this and so we can limit what the tokens are spent on to addresses on those chains if we wanted to and if this is a dow which i would assume it must be if it's a global basic income token then we can have proposals for that and what does that look like so we have our address it's going to be a pretty big number so we're going to have it be a 256 bit number when i say big i mean it can be very fractionalized so a lot of decimal places um so we have a dividend balance of that's the first variable i also know i have two minutes left so we're gonna we're gonna do this faster okay u into 256. we're kind of how many uh that balance of is our first variable that we need we also need to know how many how much dividend per token and we lastly the last thing we need to know here here is who was this credited to where did we send the token so we want to keep a record of the address that it was sent to in a decentralized way instead of on a server so that we don't send the same person uh the same token over over and over again so i'm going to write out one more function here actually since i have one minute left what i'm going to do is i'm going to write out the headers for these uh functions that i'm gonna have like i said there's gonna be a transfer function that takes the address as an input and it takes um the you know where it's from and where it's sent to as uh the parameters and then we have a value how much are we sending and lastly the last function is called approval who here is approving this the send of each of these tokens and there's a lot of different ways we can architect how approval works here we can have it so that there is no approval um we can have it so that one owner approves of everything we can have it so the network must vote on who gets it and when and i think that would be honestly better for a global basic income token we would want it to be based on a vote i think and that would be you know uh the best in person what yeah i never thought about that in-person key signing yes world coin okay so we're like let's talk really briefly about world coin we have to okay so transfer approval um and so there's there's like 40 more lines here but i'm not gonna have enough time but you guys get the basic idea by the way this is not possible today because this is a dream that i have i want it to work but nobody including myself have been able to figure out every single detail i have like a general vague idea and i just really want it to happen and that's why i kind of named this talk that i hope one of the super smart people here can work on and and make this happen i'd be happy to work on this with you in whatever form contact me afterwards i'm very interested i've always been interested in basic income and the last thing i want to talk about since we're a little bit over time but we just have to talk about world coin if we're going to talk about basic income so sam altman the yc guy made this thing called world coin and this thing had so many memes on twitter this like eyeball thing whatever the hell um and i get it it's so noble and i love it i love that they're working on this big time definitely like read the white paper for world coin i think that's a good starting point because they really put a lot of thought into the documentation behind this and here they're like solving the unique human problem remember i said like how do we prove that you're a unique person in this decentralized way um and their thought is that we're going to give everybody this robot ball thing and they're going to scan their eye and nobody else has the unique eye signature that you do so there you go and how many ways can you game this i can name a lot right you can just generate use an ai to generate a deep fake version of an i you can't sorry so you know it's like a cat and mouse game as good as we get on the security end we're gonna get just as good on the kill on the uh you know defense or the attack end so all that is to say definitely look at world coin thank you guys for being here today build with polygon i am here talk to me afterwards i love to talk to people um thank you very much [Applause]
Automatic transcript — names and jargon may be misspelled.