<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sravan Kumar Katta on Medium]]></title>
        <description><![CDATA[Stories by Sravan Kumar Katta on Medium]]></description>
        <link>https://medium.com/@sravanece222?source=rss-129564a8a824------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_XEtE8p4_sXZlV9NUVqAMQ.jpeg</url>
            <title>Stories by Sravan Kumar Katta on Medium</title>
            <link>https://medium.com/@sravanece222?source=rss-129564a8a824------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:12:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sravanece222/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Events in Solidity]]></title>
            <link>https://medium.com/@sravanece222/events-in-solidity-a6fe0814b85f?source=rss-129564a8a824------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6fe0814b85f</guid>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[web3j]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Sravan Kumar Katta]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 11:27:51 GMT</pubDate>
            <atom:updated>2022-01-18T11:27:51.540Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a continuation to my previous <a href="https://medium.com/@sravanece222/ethereum-middleware-for-java-76470e76aa33">article</a>. Please have a look for clear understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*7XUa5vR6SDOjwclp.png" /></figure><h3>Definition:</h3><p>“<em>Events are inheritable members of contracts. When you call them, they cause the arguments to be stored in the transaction’s log — a special data structure in the blockchain. These logs are associated with the address of the contract, are incorporated into the blockchain, and stay there as long as a block is accessible”</em></p><h3><strong>Need of Events in Solidity:</strong></h3><p>In a public blockchain network, all the transaction information is public and stored in it. But for easy and simple access of required information for external users, events are used.</p><p>It can be used with indexed and non-indexed formats.</p><h3>Usage in Solidity:</h3><p>As a typical programming language, the event is split into two sections</p><ol><li>Emitter</li><li>Subscriber</li></ol><h4>Emitter:</h4><p>Emitters are used within the method where information is required to emit.</p><blockquote>emit sendMessage(address senderAddress,address receiverAddress,string memory message);</blockquote><h4>Subscriber:</h4><p>The information that is emitted is received by the subscriber, only when the emit is triggered.</p><blockquote>event sendMessage(senderAddress, receiverAddress, message);</blockquote><p>For complete example, <a href="https://gist.github.com/sra122/40854037a21385a320c9fa7433eb3dd5">click here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0ITcLFhEhm79xDb9.png" /></figure><h3>How to extract Event information in Java:</h3><p>In Blockchain, every block contains its own information. So whenever there is an event triggered then the respective block needs to be reached to get the required data.</p><p>Fetching the event information are splitted into three steps</p><ol><li>Reach the Block where the event is triggered.</li><li>Add Filters like Event Name for identification.</li><li>Read data from Ethereum Log.</li></ol><h4>Step1:</h4><p>To reach the block, Web3j provides predefined constants like LATEST, EARLIST, PENDING under “DefaultBlockParameterName”. If block number is known, then we can pass it directly in the below command.</p><blockquote>EthFilter filter = new EthFilter(fromBlock, toBlock, contractAddress);</blockquote><p>Example: <br><em>EthFilter filter = new EthFilter(DefaultBlockParameterName.LATEST, DefaultBlockParameterName.LATEST, contractAddress);</em></p><h4>Step2:</h4><p>Adding filters are done in two stages. Initialy, the event should be Encoded as Signature as below.</p><blockquote>String encodedEventSignature = EventEncoder.encode(contract.EVENT_NAME);</blockquote><p>The Signature should be passed as filter topics to the parameter in step1.</p><blockquote>filter.addSingleTopic(encodedEventSignature);</blockquote><h4>Step3:</h4><p>Collected information that are wrapped under the filter are passed in the below command for fetching the event info.</p><blockquote>this.web3j.ethLogFlowable(filter).subscribe(eventString -&gt; System.out.println(eventString));</blockquote><h3>Conclusion:</h3><ol><li>Events are used to transfer data to other service.</li><li>Utilisation of events in Java using Web3j.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6fe0814b85f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethereum Middleware for Java]]></title>
            <link>https://medium.com/@sravanece222/ethereum-middleware-for-java-76470e76aa33?source=rss-129564a8a824------2</link>
            <guid isPermaLink="false">https://medium.com/p/76470e76aa33</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Sravan Kumar Katta]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 09:55:35 GMT</pubDate>
            <atom:updated>2022-01-10T09:55:35.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b5VzdjKKdfl3QEVJIjl2GQ.png" /></figure><p><strong>Introduction</strong></p><p>In the present era of web technology, we are highly reliant on the internet to seek information starting from a simple “how to turn a knob” to a complicated algorithm. The Web became a common utility in our daily lives. Adapting to the demands and requirements, the web evolved from version 1.0 to the current 3.0. Web 3.0 focuses on decentralization and data protection.</p><p>In the decentralization concept, data is stored in blocks which are connected each other using key. This series of joining the blocks and storing the data are named as Blockchain Technology. The companies/networks like Bitcoin, Ethereum are using this technology.</p><p>Discussing about the development process of Ethereum, there are two kinds of developer roles. <strong>Core Blockchain developers</strong>, who are involved in upgrading the protocols of Decentralized applications. Another type is <strong>Blockchain software developers</strong>, they are involved in developing the (Decentralized Applications) Daaps with contracts to run on blockchain technology.</p><p>This article provides an introduction about Daaps development under Ethereum using the traditional programming language Java.</p><p><strong>Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CRq5xeQqobcv4jNlB4hr-g.png" /><figcaption>Web3j Middleware for Java Application</figcaption></figure><p>The core element to start working with Ethereum is Smart Contract. The interaction and data storage in Ethereum is done based on the Smart contract, which uses Solidity programming language. But to use it as a complete Daap, we need other features like Authentication, User Interface etc. For this reason, it should be converted into the other programming language that satisfies the requirements.</p><p>Using web3j package, the wrapper class is built in Java. This will act as a middleware for interacting with Ethereum. Installation details can be <a href="https://github.com/web3j/web3j">found here</a>.</p><p><strong>Solidity</strong></p><p>Solidity is an Object-oriented programming, which is used to develop Daaps. This can be done with a simple notepad by following the installation that is mentioned <a href="https://docs.soliditylang.org/en/v0.5.3/installing-solidity.html">here</a>. But to make the process quick, in this article we are following the <a href="http://remix.ethereum.org/">Remix</a> ide, which is ready for the programming environment.</p><p>Sample Helloworld smart contract can be found <a href="https://gist.github.com/sra122/52845abe27517ee38c813b9082f7e1e5">here</a>.</p><p>After completing the smart contract development, it is supposed to compile the code to generate Application Binary Interface (abi) and Binary (bin) data, which are used in creating the wrapper class. Collect the abi and bin code and place them in separate files as Helloworld.abi and Helloworld.bin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/1*7ypZx6FRSN1lNvA2qA-7iQ.png" /><figcaption>ABI and ByteCode location.</figcaption></figure><p>Below command will be used to generate the wrapper class using the above files that are mentioned.</p><p><em>web3j generate solidity -a=Helloworld.abi -b=Helloworld.bin -o=output_directory -p=java_package</em></p><p><strong><em>Hint</em></strong><em>:</em> After generating the wrapper class, the BINARY variable is filled with json that contains functionDebungData, generateSources, linkReference, object variables etc. Replace complete json with <em>object </em>variable value alone. This will avoid errors while deploying the contract.</p><p>Place the wrapper class inside the Java Application. To start using the wrapper class, we need to collect ethereum network url, account key and private key. After successfully creating an account on ethereum network all these information will be provided. But for deploying the contract and doing operation ether needs to be spent, which is an expensive one. For the development process, we use a test network (Rinkby) using the wallet named Metamask. It is available as a browser extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QH4tEuFpmMVZ0WlmyB0tgA.png" /><figcaption>Metamask</figcaption></figure><p>After collecting all the information, initialize for connecting to the network using the below command.</p><p><em>Web3j web3j = Web3j.build(new HttpService(network_url));</em></p><p><em>Credentials credentials = Credentials.create(private_key);</em></p><p><strong><em>Hint:</em></strong> Use <em>web3j</em> and <em>credentials</em> objects as public variables, as they are used in every call.</p><p><strong>Deploying contract:</strong></p><p>By default wrapper class provides methods for deploying and loading back the contract.</p><p><em>HelloworldClass helloworld = HelloworldClass.deploy(web3j, credentials, (new ContractGasProviderClass)).send();</em></p><p><em>helloworld</em> object by default contains <em>getAddress()</em> method that contains the contract address, which is also used in loading the contract.</p><p><strong><em>Hint: </em></strong>If we can store the contract address in Database, we can just load the contract without re-deploying it again.</p><p><em>HelloworldClass helloworld = HelloworldClass.load(helloworld.getAddress(), web3j, credentials, (new ContractGasProviderClass));</em></p><p>After loading/deploying the contract, the rest of the interaction with methods that are defined in the contract is done by using the <em>HelloworldClass</em> object. For instance, there is a method <em>getName()</em> inside the contract. It is interacted as below.</p><p><em>String name = helloworld.getName().send();</em></p><p>As in the contract, getName() method contains the return type as String, the value that responds can be assured as String. But if there is no return type like <em>setName()</em> method, then by default the response would be in <em>TransactionReceipt. </em>The method <em>send()</em> is to specify request to contract.</p><p><em>TransactionReceipt transactionReceipt = helloworld.setName(“Jerry”).send();</em></p><p>TransactionReceipt contains the complete log information about the transaction. To get an overview of the transaction log, <a href="https://etherscan.io/">here</a> is an example.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76470e76aa33" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>