# Smart Contracts in Java - David Roon

- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2017-10-09
- Duration: 15:39
- Topics: blockchain, smart contracts, distributed ledger, ethereum, java
- Watch: https://streameth.org/watch/yt-KWeNSvori4I
- YouTube: https://www.youtube.com/watch?v=KWeNSvori4I

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more.
https://archive.devcon.org/archive/watch/2/smart-contracts-in-java

David Roon gives his talk on Smart Contracts in Java. 

Speaker(s): David Roon
Skill level: Advanced
Track: Developer Infrastructure
Keywords: javascript, tools, api, abi, communication, demo, code, error, documentation, android, jvm, adoption, enterprise, dapps

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 2 was held in Shanghai, China on Sep 19 - 21, 2016.
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

okay hi everyone okay I didn't think it was so emotional to talk about Java but I hope it's okay for everybody else um so I hope it will be okay because I see it's a bit too large but uh yeah maybe we can just oh I see yeah okay like that should be okay okay so hi again everyone and um I'm going to talk today about smart contracts in Java and the work I've been doing lately so just to give um a context of who I am where I come from so I'm on the functional programming and type system lover I like my types I like the compiler working for me um really into distributed system and this is actually what uh brought me to ethereum was working on a distributed open data um application I was looking for a way to have distributed metadata management system with a Provence um verification and while looking for it I discovered ethereum about um year and so ago and that made me a blockchain addict because it was so great to suddenly you can do all this security and proof and uh just amazing and what I want is a strong Java community on ethereum I think that us the Java people are a bit alone in in in all the ethereum stuff and it would be nice to come along and do uh aome application together so what is this library and why it exists so as I said I um when I started to try to do stuff with ethereum I I looked at ethereum J for any Java guys who tried it it's great but it's not so easy to use it was really hard to set up it's really hard to connect to a network really hard to have a a key pair on it it was really frustrating and so I started to build on that trying to build stuff with it and it became slowly my personal learning tool I learned a lot with ethereum uh with this library on ethereum how it works the internals how you create your transaction and so on and so forth and so it became more and more important for me to have to help other people trying to experiment with ethereum and doing DBS on it so what is this uh eth contract API so it's more of an integration Library it's a way to have in your Java some smart contracts as a service same way you have red services or I don't know which services that you know in the Java world then you can have Smart contracts as well uh with an emphasis on the type safety so that the compiler helps you and works for you and the easy integration so that you shouldn't have to think about okay what are the kind of types that you have in solidity and how do they translate in Java it should be automatic so I've been working on it for quite some time and today what you can already do is that your smart contract is uh represented by an interface a Java interface that has that will be validated against the AI so that the parameters input and output uh are correct and work with it all the communication is abstracted away so means that you don't need to think about how to to set up your node or how to connect on RPC all these things you will have a a provider to to connect to it and then you simply use it you don't have to think about it because I I was working with the existing networks there is um a pre defined provider for The Ether cam test net the mod test net and the main net it's fully nonblocking so you don't have to do all the synchronization whether your transaction has been mine or anything you get a future back and then when it's done it's done and as much as possible implicit data fun uh conversion so let's see some codes of how does it work and how you do something on it so basically you create your environment here so it's this ethereum facade um and then you get your key um of course because I don't know if you guys have done something on ether uh but they all they're using always this spring uh wallet so you don't really have a key store but you can use the same concept to take your key store from M so you will you would have to give the the K ID here and get the password afterwards and then you start your ethereum net uh or environment you read your solidity code you want to work against in this case I published the contract but you don't have to you can also simply um use the the existing address and then you create the proy object and then you use it here for example I've created a function called register this is a another project I'm working on to have a distributed App Store so here you would publish your your new app and a way to get it with a check s to make sure that when people download it they download The Right Stuff and here you will have the the interface so I I'm not going to show the exact interface but I will show another one and explain a bit the the the convention of how an interface has to be written so basically the rule is like that if you give back a completable future it means that it won't be a called but one that will create a transaction and you define what kind of value you want to get in return if it's void it's a fire and forget it means that you want to create transaction you don't really care when it's going to happen and otherwise you have all the constant calls and here as I said there was there is this um uh implicit conversion so string is string you can also have the arrays will give you list and if you have your own return type it will take all the parameters that you get back find the Constructor and if there is one matching we create the the object so this way all these things that can be sometimes frustrating that you cannot return struct and then you have to uh make them back again here it's done automatically and so where do I want to go with this Library my the biggest dream would be that it's compatible with Android we going to think that doing a a mobile apps could be really really cool um better error handling because I've been doing that for not so long so some errors are still silent it is not that good sometimes also tricky to find them the usual suspect better documentation so that people can jump on it even faster easier setup in configuration especially with the the configuration etherum J is not so it's can be a bit tricky so like to help people do that and whatever you need I mean I start already talking with a lot of developers people have great ideas different needs also sometimes you do an application that will be mobile some people will do data analysis some people would do some any other business needs that they they would have in their company big or small and so the vision of the this library is that it has to be focused on ease of use should be easy for any one even if he doesn't have a PhD in ethereum meaning if he is not really vers in it it doesn't understand all the mining process and everything should be still uh able to use it and always open to ideas always interesting to see how people use the system in different ways different needs different ideas and so my dream is that a lot of projects are cing in the GBM and we should help them use the ethereum to do that and a lot of companies are using Java and we we should help them do that as well use ethereum and I know that a lot of developers love the gvm and they also love ethereum they we need to help them join the club and have fun with the with all of us and for that I will try to create a Java Community I would like to have more and more Java developers come do dabs do things in the ethereum community and ethereum ecosystem and yeah do things together and for that I know it's always if you try to do something at work they always look at the licensing so licensing should be as friendly as possible for people to do stuff with it and my dream is to see many companies big and small to adapt ethereum because because of all the work we will do together and for that we we need you we need the the developers to do stuff on it you need feedback for people who try the the library to try it to tell me what is good what is bad what should be changed what is missing so on and so forth actually creating dabs I think that the the best way to understand how everything works is to actually do something so uh the the the thing is done in Java but actually I'm a Scala lover so I can guarantee you it works with Scala as well um and be active talk about it show it to everyone I think it's something that the livelier we're going to get more productive and we're going to be together um as I not there will be a next event end of uh November 26 and 27 the da pack in Berlin so it will be a two-day long event where people can both found out about new technologies and and also try and write some apps I will be there there will be also other other projects there that will show what they're doing and show how you can play with them senya is here you can ask her everything if you want to know anything else on that and to finish all the usual suspect how to contact me if you want to follow write send issues or try something please feel free I try to be friendly I hope I will be and um so thank you very [Applause] much are there any questions how tightly are you bound to ethereum J like you said you use RPC in between like because there is no light light line for eum yeah so right now it's working mainly on eum J and I started our Branch to work with a w web 3j which is an RPC uh implementation in Java and the idea is that for anyone using the library shouldn't make any difference so they can still use this interface to talk with a smart contract just it just so happen that it goes through the RPC and not through the note so of course there will be some limitation because today there are some stuff that are not coming back from the RPC for example the return value is not uh available if it's a true a transaction with the RPC but otherwise it would be totally transparent do you use it in production ckey or no right now is not in production but hopefully there will be a lot of project in production so no it it is written in Java the reason is that so that as many people as possible can use it but yeah I'm a Scala L if I could have written that in Scala I would have okay yes the cont interfaces um you need to provide them or is the system capable of of generating so you have to provide them the the main reason it is done like that for example web 3j they have generators to do that the reason I prefer that you define them is that you can Define what kind of value you expecting and then the conversion will take place that when it's generating you you cannot so are you basically implementing on ethereum what Lisk is doing on their own blockchain or how does it differentiate no not really because here solidity is still here I mean on the ethereum part I haven't changed anything here is the integration part that is different let's say that it's more an alternative to web 3js kind of today usually people will integrate with that and here it's another way in Java that I think is also nice because you have all the J like the you are in your environment with the type system that you don't have 3js what what what on the uh yes uh there a meod cont and the uh so here it's just an example because I'm working on this decentralized app store and the idea is that you have your organization you can publish publish their way to get it so here would be like the sorry the HTTP like the URL to download the application the idea is that you can you can put HB and then you could put ipfs you can put P whatever you want but it's always the same check s to make sure that we're talking always about the same uh the same B yes the node which is connected is is an LPC node so the so the question is about the nodes it the the back end is the idea is that the back end is abstracted away so the back end can be RPC if you choose it to be but to for example today it's an actual node using eum J so you have an actual node that is sying locally but you can choose which one you want depending on your needs
