<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Axat Bhardwaj</title>
    <description>The latest articles on DEV Community by Axat Bhardwaj (@axatbhardwaj).</description>
    <link>https://dev.to/axatbhardwaj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F860019%2F1f383f92-64ef-4b40-b131-3e88027f75a1.jpeg</url>
      <title>DEV Community: Axat Bhardwaj</title>
      <link>https://dev.to/axatbhardwaj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/axatbhardwaj"/>
    <language>en</language>
    <item>
      <title>Events In EVM</title>
      <dc:creator>Axat Bhardwaj</dc:creator>
      <pubDate>Tue, 20 Dec 2022 05:47:46 +0000</pubDate>
      <link>https://dev.to/axatbhardwaj/events-in-evm-3b7j</link>
      <guid>https://dev.to/axatbhardwaj/events-in-evm-3b7j</guid>
      <description>&lt;h2&gt;
  
  
  Events
&lt;/h2&gt;

&lt;p&gt;Solidity events give an abstraction on top of the EVM’s logging functionality. Applications can subscribe and listen to these events through the RPC interface of an Ethereum client.&lt;/p&gt;

&lt;p&gt;In the traditional world, applications often use logs to capture and describe what’s going on at a specific moment. These logs are often used to debug applications, detect specific events, or notify the viewer of the logs that something happened. It turns out they are also very useful when writing or interacting with smart contracts!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;💡 &lt;strong&gt;The Ethereum Virtual Machine (EVM) has a logging function &lt;br&gt;
that is used to write data, including Solidity events, to a structure &lt;br&gt;
outside smart contracts.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;event Deposit(address indexed from,bytes32 indexed id,uint value;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Logs and events are often referred to anonymously. Events allow you to ‘print’ information to the logging structure in a way that is more gas-efficient since the information is not stored in a storage variable, which takes up more gas. Events, or logs, live in the Transaction Receipts trie, which is inaccessible to smart contracts.&lt;/p&gt;

&lt;p&gt;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 (forever as of now, but this might change with Serenity). The Log and its event data is not accessible from within contracts (not even from the contract that created them).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;💡 To put it simply, &lt;strong&gt;events&lt;/strong&gt; are ways to communicate with a client application or front-end website that something has happened on the blockchain.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Logging in Ethereum
&lt;/h2&gt;

&lt;p&gt;The EVM currently has &lt;strong&gt;5 opcodes&lt;/strong&gt; for emitting event logs: &lt;em&gt;LOG0&lt;/em&gt;, &lt;em&gt;LOG1&lt;/em&gt;, &lt;em&gt;LOG2&lt;/em&gt;, &lt;em&gt;LOG3&lt;/em&gt;, and &lt;em&gt;LOG4&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;These opcodes can be used to create &lt;strong&gt;log records&lt;/strong&gt;. A log record can be used to describe an event within a smart contract, like a token transfer or a change of ownership.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UCBtX-0b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7fvxhtvju77b7jqzqh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UCBtX-0b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7fvxhtvju77b7jqzqh7.png" alt="Logs opcodes" width="725" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ethereum.github.io/yellowpaper/paper.pdf"&gt;Ethereum Yellowpaper&lt;/a&gt; — Byzantium Version 69351d5 (2018-12-10)&lt;/p&gt;

&lt;p&gt;💡 &lt;em&gt;Each log record consists of both &lt;strong&gt;topics&lt;/strong&gt; and &lt;strong&gt;data&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Topics are 32-byte (256 bit) “words” that are used to describe what’s going on in an event. Different opcodes (LOG0 … LOG4) are needed to describe the number of topics that need to be included in the log record. For instance, &lt;strong&gt;LOG1&lt;/strong&gt; includes &lt;strong&gt;one topic&lt;/strong&gt;, while &lt;strong&gt;LOG4&lt;/strong&gt; includes &lt;strong&gt;four topics&lt;/strong&gt;. Therefore, the maximum number of topics that can be included in a single log record is &lt;strong&gt;four&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Topics in Ethereum Log Records
&lt;/h2&gt;

&lt;p&gt;The first part of a log record consists of an array of topics. These topics are used to describe the event. &lt;/p&gt;

&lt;p&gt;A topic can only hold a single word (32 bytes)Then they appear in the structure of topics, not the data portion of the log. When parameters do not have the indexed attributes, they are ABI-encoded into the data portion of the log.&lt;/p&gt;

&lt;p&gt;Since topics can only hold a maximum of 32 bytes of data, things like arrays or strings cannot be used as topics reliably. Instead, it should be included as data in the log record, not as a topic. If you were to try including a topic that’s larger than 32 bytes, the topic will be hashed instead. As a result, this hash can only be reversed if you know the original input. In conclusion, topics should &lt;strong&gt;only&lt;/strong&gt; reliably be used for data that strongly narrows down search queries (like addresses)&lt;/p&gt;

&lt;h2&gt;
  
  
  Data in Ethereum Log Records
&lt;/h2&gt;

&lt;p&gt;The second part of a log record consists of additional data. Topics and data work best together as there are upsides and downsides to each. For example, while topics are searchable, data is not. But, including data is &lt;strong&gt;a lot cheaper&lt;/strong&gt; than including topics. Additionally, while topics are limited to &lt;strong&gt;4 * 32 bytes&lt;/strong&gt;, event data is not, which means it can include &lt;strong&gt;large or complicated data&lt;/strong&gt; like arrays or strings. Therefore, the event data (if any) can be seen as the &lt;em&gt;value.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Indexed Events
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Solidity events are interfaces with EVM logging functionality.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can add an attribute indexed to up to three parameters. which adds them to “topics” instead of the data part of the log.&lt;/p&gt;

&lt;p&gt;All parameters without the &lt;code&gt;indexed&lt;/code&gt; attribute are &lt;a href="https://docs.soliditylang.org/en/v0.8.13/abi-spec.html#abi"&gt;ABI-encoded&lt;/a&gt; into the data part of the log.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anonymous Events
&lt;/h2&gt;

&lt;p&gt;The first topic usually consists of the &lt;strong&gt;&lt;em&gt;signature&lt;/em&gt;&lt;/strong&gt; (a &lt;a href="https://en.wikipedia.org/wiki/SHA-3"&gt;keccak256&lt;/a&gt; hash) of the name of the event that occurred, including the types &lt;em&gt;(uint256, string, etc.)&lt;/em&gt; of its parameters.One exception where this signature is not included as the first topic is when emitting &lt;strong&gt;anonymous events&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The hash of the signature of the event is one of the topics, except if you declared the event with the &lt;code&gt;anonymous&lt;/code&gt; specifier. &lt;/p&gt;

&lt;p&gt;This means that it is not possible to filter for specific anonymous events by name, you can only filter by the contract address. &lt;/p&gt;

&lt;p&gt;💡 &lt;em&gt;The advantage of anonymous events is that they are cheaper to deploy and call. It also allows you to declare four indexed arguments rather than three.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;💡 The base cost of logging operations is &lt;strong&gt;375 gas&lt;/strong&gt;&lt;br&gt;
. On top of that, every included topic costs an additional &lt;strong&gt;375 gas&lt;/strong&gt;&lt;br&gt;
. Finally, each byte of data costs &lt;strong&gt;8 gas&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logs are an elegant way to store tiny amounts of data on the Ethereum blockchain for a small price. Specifically, event logs are useful to let other people know something has happened without them having to query contracts individually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://linktr.ee/axatbhardwaj"&gt;Axat Bhardwaj&lt;/a&gt;&lt;br&gt;
Blockchain Engineer&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Gas Optimization In Solidity</title>
      <dc:creator>Axat Bhardwaj</dc:creator>
      <pubDate>Fri, 16 Dec 2022 16:25:38 +0000</pubDate>
      <link>https://dev.to/axatbhardwaj/gas-optimization-in-solidity-4p49</link>
      <guid>https://dev.to/axatbhardwaj/gas-optimization-in-solidity-4p49</guid>
      <description>&lt;h1&gt;
  
  
  EVM Gas optimization tricks
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Main Gas optimization areas in solidity
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Operations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Storage
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Saving one variable in storage costs 20,000 gas (Check gas used by EVM opcodes)&lt;/li&gt;
&lt;li&gt;5,000 gas when we rewrite the variable&lt;/li&gt;
&lt;li&gt;reading from the slot take 200 gas&lt;/li&gt;
&lt;li&gt;But storage variable declaration doesn't cost anything, as there's no initialization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;always save a storage variable in memory in a function&lt;/li&gt;
&lt;li&gt;if you wanna update a storage variable then first calculate everything in the memory variables&lt;/li&gt;
&lt;li&gt;organize &amp;amp; try to pack two or more storage variables into one it's much cheaper&lt;/li&gt;
&lt;li&gt;also while using structs, try to pack them&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Refunds
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Free storage slot by zeroing corresponding variables as soon as you don't need them anymore. This will refund 15,000 of gas.&lt;/li&gt;
&lt;li&gt;Removing a contract by using &lt;code&gt;Selfdestruct&lt;/code&gt; opcodes refunds 24,000 gas. But a refund must not surpass half the gas that the ongoing contract call uses.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data types and packing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use bytes32 whenever possible, because it is the most optimized storage type.&lt;/li&gt;
&lt;li&gt;If the length of bytes can be limited, use the lowest amount possible from bytes1 to bytes32.&lt;/li&gt;
&lt;li&gt;Using bytes32 is cheaper than using string&lt;/li&gt;
&lt;li&gt;Variable packing only occurs in storage — memory and call data does not get packed. &lt;/li&gt;
&lt;li&gt;You will not save space trying to pack function arguments or local variables&lt;/li&gt;
&lt;li&gt;Storing a small number in a uint8 variable is not cheaper than storing it in uint256 because the number in uint8 is padded with numbers to fill 32 bytes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Inheritance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;when we extend a contract, the variables in the child can be packed with the variables in the parent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The order of variables is determined by &lt;a href="https://en.wikipedia.org/wiki/C3_linearization"&gt;C3 linearization&lt;/a&gt;, all you need to know is that child variables come after parent variables.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Memory vs Storage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;copying between the memory and storage will cost some gas, so don't copy arrays from storage to memory, use a &lt;a href="https://blog.b9lab.com/storage-pointers-in-solidity-7dcfaa536089"&gt;storage pointer&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the cost of memory is complicated. you "buy" it in chunks, the cost of which will go up quadratically after a while&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try adjusting the location of your variables by playing with the keywords "storage" and "memory". Depending on the size and number of copying operations between Storage and memory, switching to memory may or may not give improvements. All this is because of varying memory costs. So optimizing here is not that obvious and every case has to be considered individually.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Avoid public variables&lt;/li&gt;
&lt;li&gt;Use global variables efficiently&lt;/li&gt;
&lt;li&gt;it is good to use global variables with private visibility as it saves gas&lt;/li&gt;
&lt;li&gt;Use events rather than storing data&lt;/li&gt;
&lt;li&gt;Use memory arrays efficiently&lt;/li&gt;
&lt;li&gt;Use return values efficiently&lt;/li&gt;
&lt;li&gt;A simple optimization in Solidity consists of naming the return value of a function. It is not needed to create a local variable then.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Mapping vs Array
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use mapping whenever possible, it's cheap instead of the array&lt;/li&gt;
&lt;li&gt;But an array could be a good choice if you have a small array&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Fixed vs Dynamic
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fixed size variables are always cheaper than dynamic ones.&lt;/li&gt;
&lt;li&gt;It's good to use memory arrays if the size of the array is known, fixed-size memory arrays can be used to save gas.&lt;/li&gt;
&lt;li&gt;If we know how long an array should be, we specify a fixed size&lt;/li&gt;
&lt;li&gt;This same rule applies to strings. A string or bytes variable is dynamically sized; we should use a byte32 if our string is short enough to fit.&lt;/li&gt;
&lt;li&gt;If we absolutely need a dynamic array, it is best to structure our functions to be additive instead of subtractive. Extending an array costs constant gas whereas truncating an array costs linear gas.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;use external most of the time whenever possible&lt;/li&gt;
&lt;li&gt;Each position will have an extra 22 gas, so

&lt;ul&gt;
&lt;li&gt;Reduce public variables&lt;/li&gt;
&lt;li&gt;Put often-called functions earlier&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;reduce the parameters if possible (Bigger input data increases gas because more things will be stored in memory)&lt;/li&gt;
&lt;li&gt;payable function saves some gas as compared to non-payable functions (as the compiler won't have to check)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  View Functions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You are not paying for view functions but this doesn't mean they aren't consuming gas, they do.&lt;/li&gt;
&lt;li&gt;it cost gas when calling in a tx&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Loops
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;use memory variables in loops&lt;/li&gt;
&lt;li&gt;try to avoid unbounded loops&lt;/li&gt;
&lt;li&gt;write uint256 index; instead of writing uint256 index = 0; as being a uint256, it will be 0 by default so you can save some gas by avoiding initialization.&lt;/li&gt;
&lt;li&gt;if you put &lt;code&gt;++&lt;/code&gt; before &lt;code&gt;i&lt;/code&gt; it costs less gas&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Order
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Order cheap functions before

&lt;ul&gt;
&lt;li&gt;f(x) is cheap&lt;/li&gt;
&lt;li&gt;g(y) is expensive&lt;/li&gt;
&lt;li&gt;ordering should be&lt;/li&gt;
&lt;li&gt;f(x) || g(y)&lt;/li&gt;
&lt;li&gt;f(x) &amp;amp;&amp;amp; g(y)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use Short-Circuiting rules to your advantage
&lt;/h3&gt;

&lt;p&gt;When using logical disjunction (||), logical conjunction (&amp;amp;&amp;amp;), make sure to order your functions correctly for optimal gas usage. In logical disjunction (OR), if the first function resolves to true, the second one won’t be executed and hence save you gas. In logical disjunction (AND), if the first function evaluates to false, the next function won’t be evaluated. Therefore, you should order your functions accordingly in your solidity code to reduce the probability of needing to evaluate the second function.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using unchecked
&lt;/h3&gt;

&lt;p&gt;Use unchecked for arithmetic where you are sure it won't over or underflow, saving gas costs for checks added from solidity v0.8.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Optimizations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Remove the dead code&lt;/li&gt;
&lt;li&gt;Use different solidity versions and try&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EXTCODESIZE&lt;/code&gt; is quite expensive, this is used for calls between contracts, the only option we see to optimize the code in this regard is minimizing the number of calls to other contracts and libraries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Libraries
&lt;/h3&gt;

&lt;p&gt;When a public function of a library is called, the bytecode of that function is not made part of a client contract. Thus, complex logic should be put in libraries (but there is also the cost of calling the library function)&lt;/p&gt;

&lt;h3&gt;
  
  
  Errors
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use "require" for all runtime conditions validations that can't be prevalidated on the compile time. And "assert" should be used only for static validation that normally fails never fail on a properly functioning code.&lt;/li&gt;
&lt;li&gt;string size in require statements can be shortened to reduce gas.&lt;/li&gt;
&lt;li&gt;A failing "assert" consumer all the gas available to the call, while "require" doesn't consume any.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Hash functions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;keccak256: 30 gas + 6 gas for each word of input data&lt;/li&gt;
&lt;li&gt;sha256: 60 gas + 12 gas for each word of input data&lt;/li&gt;
&lt;li&gt;ripemd160: 600 gas + 120 gas for each word of input data&lt;/li&gt;
&lt;li&gt;So if you don't have any specific reasons to select another hash function, just use keccak256&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use ERC1167 To Deploy the same Contract many times
&lt;/h3&gt;

&lt;p&gt;EIP1167 minimal proxy contract is a standardized, gas-efficient way to deploy a bunch of contract clones from a factory.EIP1167 not only minimizes length, but it is also literally a “minimal” proxy that does nothing but proxying. It minimizes trust. Unlike other upgradable proxy contracts that rely on the honesty of their administrator (who can change the implementation), the address in EIP1167 is hardcoded in bytecode and remain unchangeable&lt;/p&gt;

&lt;h2&gt;
  
  
  Merkle proof
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Merkle tree can be used to prove the validity of a large amount of data using a small amount of data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools for estimating gas
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Remix&lt;/li&gt;
&lt;li&gt;Truffle&lt;/li&gt;
&lt;li&gt;Eth Gas reporter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy Learning !!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://linktr.ee/axatbhardwaj"&gt;Axat Bhardwaj&lt;/a&gt;&lt;br&gt;
Blockchain Engineer&lt;/p&gt;

</description>
      <category>solidity</category>
      <category>gasoptimization</category>
      <category>ethereum</category>
      <category>smartcontracts</category>
    </item>
    <item>
      <title>Tron Private network setup (Complete guide 2022)</title>
      <dc:creator>Axat Bhardwaj</dc:creator>
      <pubDate>Tue, 10 May 2022 06:15:04 +0000</pubDate>
      <link>https://dev.to/axatbhardwaj/tron-private-network-setup-complete-guide-2022-2pa2</link>
      <guid>https://dev.to/axatbhardwaj/tron-private-network-setup-complete-guide-2022-2pa2</guid>
      <description>&lt;h1&gt;
  
  
  Tron network setup
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Prereq
&lt;/h2&gt;

&lt;p&gt;Have necessary pre req installs&lt;/p&gt;

&lt;p&gt;I have used Ubuntu as my host OS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get -y install apt-transport-https ca-certificates
sudo apt-get install -y build-essential checkinstall libssl-dev

mkdir ~/nftron
cd ~/nftron

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;copy paste in the current shell&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'JDK_MD5="0029351f7a946f6c05b582100c7d45b7"
JDK_DIR="jdk1.8.0_202"
JDK_TAR="jdk-8u202-linux-x64.tar.gz"
JAVA_HOME=/usr/local/$JDK_DIR
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME=/usr/local/$JDK_DIR' &amp;gt; .envs

source .envs

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Lets install Java
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo wget -P /usr/local &amp;lt;https://github.com/frekele/oracle-java/releases/download/8u202-b08/$JDK_TAR&amp;gt;

echo "Ensure you have "OK" status for chksum"

sudo echo "$JDK_MD5 /usr/local/$JDK_TAR" | md5sum -c
sudo tar -zxf /usr/local/$JDK_TAR -C /usr/local

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will move with three tron repos for now,&lt;br&gt;
1, Tron private network Deployment -&lt;br&gt;
&lt;code&gt;git clone &amp;lt;https://github.com/tronprotocol/java-tron.git&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2, Tron wallet address creation&lt;br&gt;
&lt;code&gt;git clone &amp;lt;https://github.com/tronprotocol/wallet-cli.git&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3, Tronbox for compiler &amp;amp; smart contract deployment ,   equalent to truffle&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;https://github.com/tronprotocol/tronbox.git&amp;gt;

or
you can use npm install -g tronbox

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  1. Now you have set all prerequisites, we will build tron network now
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo  "Building the  Source code "

cd ~/nftron/java-tron
./gradlew build

mkdir srnode
cd srnode
cp ~/nftron/java-tron/build/libs/FullNode.jar .
cp ~/nftron/java-tron/build/libs/SolidityNode.jar .
cp ~/nftron/java-tron/framework/build/resources/main/config.conf .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Lets start the node
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar ./FullNode.jar --witness -c ../config.conf

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  To start Solidity node (optional)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar ./FullNode.jar  -c ../config.conf

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Now lets start wallet -cli
&lt;/h2&gt;

&lt;p&gt;Clone the repo from above link&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/nftron/wallet-cli
cp src/main/resources/config.conf ~/nftron/wallet-cli/

#Modify the config.conf in src/main/resources with the fullnode/solidity details.
ie. port number or ip address if its different ec2 instance.

./gradlew build

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now you can run the wallet&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar build/libs/wallet-cli.jar

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1,  Register wallet&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;registerwallet user1&lt;br&gt;
(input your complex password)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;2, login with register user&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;login user1&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;3,  generate the account for tests&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;generateaddress&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;{&lt;br&gt;
"address": "27abQWJo3mc2b6kRY8Dng8ZzE7GWGpNgFpF",&lt;br&gt;
"privateKey": "f70c5503e6f7e83a76f12373ddb478bfd04f10b4f78de5046a7dc75532f84c81"&lt;br&gt;
}&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Now lets do with Tronbox for solidity code deployment on the private network
&lt;/h2&gt;

&lt;p&gt;You can clone the repo or use npm commands to install&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install  -g tronbox
mkdir samplecode
cd samplecode
tronbox init

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note : Edit the tronbox.js file and update the fullnode ip address and port and private key in developement&lt;br&gt;
&lt;code&gt;tronbox.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use the below solidity sample contracts, just copy paste in the current shell&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'pragma solidity &amp;gt;=0.4.23 &amp;lt;0.9.0;
contract Test{
function f() public pure returns (string memory){
return "method f()";
}
function g() public pure returns (string memory){
return "method g()";
}
}' &amp;gt; samplecode/contracts/Test.sol

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'var Test = artifacts.require("./Test.sol");
var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {

deployer.deploy(Test);
deployer.deploy(Migrations);
}; '  &amp;gt; samplecode/migrations/2_deploy_contracts.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets compile and migrate&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tronbox compile
tronbox migrate --network development

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cheers !!&lt;br&gt;
Axat Bhardwaj&lt;br&gt;
Blockchain Developer &amp;amp; Technologist&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/axatbhardwaj"&gt;https://www.linkedin.com/in/axatbhardwaj&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
    </item>
    <item>
      <title>The Tron protocol (Blockchain) a Deep Dive in 2022</title>
      <dc:creator>Axat Bhardwaj</dc:creator>
      <pubDate>Mon, 09 May 2022 21:25:48 +0000</pubDate>
      <link>https://dev.to/axatbhardwaj/the-tron-protocol-blockchain-a-deep-dive-in-2022-4iah</link>
      <guid>https://dev.to/axatbhardwaj/the-tron-protocol-blockchain-a-deep-dive-in-2022-4iah</guid>
      <description>&lt;h1&gt;
  
  
  TRON
&lt;/h1&gt;

&lt;p&gt;The TRON Protocol, one of the largest blockchain-based operating systems in the&lt;br&gt;
world, offers public blockchain support of high throughput, high scalability, and high availability for&lt;br&gt;
all Decentralized Applications (DApps) in the TRON ecosystem&lt;/p&gt;
&lt;h1&gt;
  
  
  Progression from inception of project
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The TRON Foundation was established in July 2017 in Singapore.&lt;/li&gt;
&lt;li&gt;In December 2017, TRON had
launched its open source protocol. The Testnet, Blockchain Explorer, and Web Wallet were all
launched by March 2018.&lt;/li&gt;
&lt;li&gt;TRON Mainnet launched shortly afterward in May 2018, marking the Odyssey 2.0 release as a technical milestone.&lt;/li&gt;
&lt;li&gt;In June 2018, TRON declared its independence with
the creation of the Genesis block, along with the July 2018 acquisition of BitTorrent.&lt;/li&gt;
&lt;li&gt;In October 2018, TRON launched the TRON Virtual Machine (TVM), a complete developers’ toolset, and 360
support system. The TRON roadmap involves combining BitTorrent’s 100 million users with the
TRON network via Project Atlas, as well as fostering the developer community to launch exciting
new DApps on the TRON network.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Architecture
&lt;/h1&gt;


💡 The Following article is by the founder of the TRON himself so have a look at it ,



&lt;p&gt;&lt;a href="https://www.gemini.com/cryptopedia/tron-coin-blockchain-architecture#section-tron-virtual-machine-tvm"&gt;The TRON Blockchain's Technical Architecture | Gemini&lt;/a&gt;&lt;/p&gt;


💡 The below link is for the architecture of tron (official PDF)



&lt;p&gt;&lt;a href="https://tron.network/static/doc/Design_Book_of_TRON_Architecture.pdf"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TRON adopts &lt;strong&gt;a 3-layer architecture&lt;/strong&gt; divided into Storage Layer, Core Layer, and Application Layer.&lt;/p&gt;

&lt;p&gt;The TRON protocol adheres to Google Protobuf, which intrinsically supports multi-language&lt;br&gt;
extension&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xy6BsxW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/v1/TRON%207282c567698a4d6992a3956d92a25454/tron_001.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xy6BsxW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/v1/TRON%207282c567698a4d6992a3956d92a25454/tron_001.png" alt="Diagram of 3 layer architecture of Tron" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Diagram of 3 layer architecture of Tron&lt;/p&gt;
&lt;h2&gt;
  
  
  3-layers
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Core Layer
&lt;/h3&gt;

&lt;p&gt;There are several modules in the core layer, including smart contracts, account management, and&lt;br&gt;
consensus. A stack-based virtual machine is implemented on TRON and an optimized instruction&lt;br&gt;
set is used. In order to better support DApp developers, Solidity was chosen as the smart contract&lt;br&gt;
language, followed by future support of other advanced languages. In addition, TRON's consensus&lt;br&gt;
mechanism is based on Delegated Proof of Stake (DPoS) and many innovations were made in&lt;br&gt;
order to meet its unique requirements.&lt;/p&gt;
&lt;h3&gt;
  
  
  Storage Layer
&lt;/h3&gt;

&lt;p&gt;TRON designed a unique distributed storage protocol consisting of Block Storage and State&lt;br&gt;
Storage. The notion of a graph database was introduced into the design of the storage layer to&lt;br&gt;
better meet the need for diversified data storage in the real world&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Blockchain Storage :-
TRON blockchain storage chooses to use LevelDB, which is developed by Google and proven
successful with many companies and projects. It has high performance and supports arbitrary byte
arrays as both keys and values, singular get, put and delete, batched put and delete, bi-directional
iterators, and simple compression using the very fast Snappy algorithm.&lt;/li&gt;
&lt;li&gt;State Storage :-
TRON has a KhaosDB in the full-node memory that can store all the newly forked chains generated
within a certain period of time and supports witnesses to switch from their own active chain swiftly
into a new main chain. It can also protect blockchain storage by making it more stable from being
terminating abnormally in an intermediate state.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Application Layer
&lt;/h3&gt;

&lt;p&gt;Developers can create a diverse range of DApps and customized wallets on TRON. Since TRON&lt;br&gt;
enables smart contracts to be deployed and executed, the opportunities of utility applications are unlimited.&lt;/p&gt;
&lt;h2&gt;
  
  
  Protocol
&lt;/h2&gt;

&lt;p&gt;TRON protocol adheres to &lt;a href="https://developers.google.com/protocol-buffers/"&gt;Google Protocol Buffers&lt;/a&gt;, which is a language-neutral, platform-neutral,&lt;br&gt;
and extensible way of serializing structured data for use in communications protocols, data storage,&lt;br&gt;
and more.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are protocol Buffers ?
&lt;/h3&gt;

&lt;p&gt;Protocol Buffers (Protobuf) is a flexible, efficient, automated mechanism for serializing structured&lt;br&gt;
data, similar to JSON or XML, but much smaller, faster and simpler.&lt;br&gt;
Protobuf (.proto) definitions can be used to generate code for C++, Java, C#, Python, Ruby,&lt;br&gt;
Golang, and Objective-C languages through the official code generators. Various third-party&lt;br&gt;
implementations are also available for many other languages. Protobuf eases development for&lt;br&gt;
clients by unifying the API definitions and also optimizing data transfers. Clients can take the API&lt;br&gt;
.proto from TRON’s protocol repository and integrate through the automatically-generated code&lt;br&gt;
libraries.&lt;br&gt;
As a comparison, Protocol Buffers is 3 to 10 times smaller and 20 to 100 times faster than XML,&lt;br&gt;
with less ambiguous syntax. Protobuf generates data access classes that are easier to use&lt;br&gt;
programmatically.&lt;/p&gt;


&lt;h1&gt;
  
  
  Decentralized Exchange (DEX)
&lt;/h1&gt;

&lt;p&gt;The TRON network natively supports decentralized exchange functions. A decentralized exchange&lt;br&gt;
consists of multiple trading pairs. A trading pair (notation “Exchange”) is an Exchange Market&lt;br&gt;
between TRC-10 tokens, or between a TRC-10 token and TRX. Any account can create a trading&lt;br&gt;
pair between any tokens, even if the same pair already exists on the TRON network. Trading and price fluctuations of the trading pairs follow the Bancor Protocol. The TRON network stipulates that the weights of the two tokens in all trading pairs are equal, so the ratio of their balances is the price between them.&lt;/p&gt;


💡 The TRON blockchain code is implemented in Java and was originally a fork from EthereumJ.




&lt;h1&gt;
  
  
  Consensus
&lt;/h1&gt;

&lt;p&gt;The Tron Uses DPoS&lt;/p&gt;
&lt;h2&gt;
  
  
  Delegated Proof of Stake (DPoS)
&lt;/h2&gt;

&lt;p&gt;In PoS networks, token holders lock their token balances to become block&lt;br&gt;
validators. The validators take turns proposing and voting on the next block. However, the problem&lt;br&gt;
with standard PoS is that validator influence correlates directly to the amount of tokens locked up.&lt;br&gt;
This results in parties hoarding large amounts of the network’s base currency wielding undue&lt;br&gt;
influence in the network ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The TRON consensus mechanism uses an innovative Delegated Proof of Stake system&lt;/strong&gt; in which 27&lt;br&gt;
Super Representatives (SRs) produce blocks for the network. Every 6 hours, TRX account holders&lt;br&gt;
who freeze their accounts can vote for a selection of SR candidates, with the top 27 candidates&lt;br&gt;
deemed the SRs. Voters may choose SRs based on criteria such as projects sponsored by SRs to increase TRX adoption, and rewards distributed to voters. This allows for a more democratized and decentralized ecosystem. SRs’ accounts are normal accounts, but their accumulation of votes&lt;br&gt;
allows them to produce blocks. With the low throughput rates of Bitcoin and Ethereum due to their PoW consensus mechanism and scalability issues, TRON’s DPoS system offers an innovative mechanism resulting in 2000 TPS compared to Bitcoin’s 3 TPS and Ethereum’s 15 TPS.&lt;br&gt;
The TRON protocol network generates one block every three seconds, with each block awarding 32&lt;br&gt;
TRX to Super Representatives. A total of 336,384,000 TRX will be awarded annually to the 27 SRs.&lt;br&gt;
Each time an SR finishes block production, rewards are sent to a sub-account in the super-ledger.&lt;br&gt;
SRs can check, but not directly make use of these TRX tokens. A withdrawal can be made by each&lt;br&gt;
SR once every 24 hours, transferring the rewards from the sub-account to the specified SR account.&lt;/p&gt;

&lt;p&gt;For more details refer to this :-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://coredevs.medium.com/the-basics-of-trons-dpos-consensus-algorithm-db12c52f1e03"&gt;The Basics of TRON's DPoS Consensus Algorithm&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The three types of nodes on the TRON network are Witness Node, Full Node, and Solidity Node.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Witness nodes are set up by SRs and are mainly responsible for block production and proposal creation/voting.&lt;/li&gt;
&lt;li&gt;Full nodes provide APIs and broadcast transactions and blocks.&lt;/li&gt;
&lt;li&gt;Solidity nodes sync blocks from other Full Nodes and also provide indexable APIs.&lt;/li&gt;
&lt;/ul&gt;


💡 SR = Super Representative(Block Producers)




&lt;h1&gt;
  
  
  Account
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Types
&lt;/h2&gt;

&lt;p&gt;The three types of accounts in the TRON network are regular accounts, token accounts, and&lt;br&gt;
contract accounts.&lt;br&gt;
1.Regular accounts are used for standard transactions.&lt;/p&gt;

&lt;p&gt;2.Token accounts are used for storing TRC-10 tokens.&lt;/p&gt;

&lt;p&gt;3.Contract accounts are smart contract accounts created by regular accounts and can be triggered by regular accounts as well.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creation
&lt;/h2&gt;

&lt;p&gt;There are three ways to create a TRON account:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new account through API&lt;/li&gt;
&lt;li&gt;Transfer TRX into a new account address&lt;/li&gt;
&lt;li&gt;Transfer any TRC-10 token into a new account address&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Structure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;account_name: the name for this account – e.g. BillsAccount.&lt;/li&gt;
&lt;li&gt;type: what type of this account is – e.g. 0 (stands for type ‘Normal’).&lt;/li&gt;
&lt;li&gt;balance: balance of this account – e.g. 4213312.
16&lt;/li&gt;
&lt;li&gt;vote: received votes on this account – e.g. {(“0x1b7w...9xj3”,323),
(“0x8djq...j12m”,88),...,(“0x82nd...mx6i”,10001)}.&lt;/li&gt;
&lt;li&gt;asset: other assets expected TRX in this account – e.g. {&amp;lt;“WishToken”, 66666&amp;gt;, &amp;lt;”Dogie”,
233&amp;gt;}.&lt;/li&gt;
&lt;li&gt;latest_operation_time: the latest operation time of this account.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="nx"&gt;Account&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="nx"&gt;Vote&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;vote_address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;int64&lt;/span&gt; &lt;span class="nx"&gt;vote_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;accout_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;AccountType&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;int64&lt;/span&gt; &lt;span class="nx"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;repeated&lt;/span&gt; &lt;span class="nx"&gt;Vote&lt;/span&gt; &lt;span class="nx"&gt;votes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;int64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;asset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;int64&lt;/span&gt; &lt;span class="nx"&gt;latest_operation_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;AccountType&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;Normal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;AssetIssue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;Contract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Block
&lt;/h1&gt;

&lt;p&gt;A block typically contains a block header and several transactions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="nx"&gt;Block&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;BlockHeader&lt;/span&gt; &lt;span class="nx"&gt;block_header&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;repeated&lt;/span&gt; &lt;span class="nx"&gt;Transaction&lt;/span&gt; &lt;span class="nx"&gt;transactions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Block Header
&lt;/h2&gt;

&lt;p&gt;Raw data is denoted as raw_data in Protobuf. It contains the raw data of a message,containing 6 parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;timestamp: timestamp of this message – e.g. 1543884429000.&lt;/li&gt;
&lt;li&gt;txTrieRoot: the Merkle Tree’s Root – e.g. 7dacsa...3ed.&lt;/li&gt;
&lt;li&gt;parentHash: the hash of the last block – e.g. 7dacsa...3ed.&lt;/li&gt;
&lt;li&gt;number: the block height – e.g. 4638708.&lt;/li&gt;
&lt;li&gt;version: reserved – e.g. 5.&lt;/li&gt;
&lt;li&gt;witness_address: the address of the witness packed in this block – e.g. 41928c...4d21.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="nx"&gt;BlockHeader&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;int64&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;txTrieRoot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;parentHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;uint64&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;uint64&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;witness_address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;witness_signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="nx"&gt;blockID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Witness signature is denoted as witness_signature in Protobuf, which is the signature for this block header from the witness node.&lt;/p&gt;

&lt;p&gt;💡 Block ID is denoted as blockID in Protobuf. It contains the atomic identification of a block. A Block&lt;br&gt;
ID contains 2 parameters:&lt;br&gt;
hash: the hash of block.&lt;br&gt;
number: the hash and height of the block.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transactions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Signing :-
&lt;/h3&gt;

&lt;p&gt;TRON’s transaction signing process follows a standard ECDSA cryptographic algorithm, with a SECP256K1 selection curve. A private key is a random number, and the public key is a point on the elliptic curve. The public key generation process consists of first generating a random number as a&lt;br&gt;
private key, and then multiplying the base point of the elliptic curve by the private key to obtain the public key. When a transaction occurs, the transaction raw data is first converted into byte format.&lt;br&gt;
The raw data then undergoes SHA-256 hashing. The private key corresponding to the contract&lt;br&gt;
address then signs the result of the SHA256 hash. The signature result is then added to the transaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bandwidth Model :-
&lt;/h3&gt;

&lt;p&gt;Ordinary transactions only consume bandwidth points, but smart contract operations consume both&lt;br&gt;
energy and bandwidth points. There are two types of bandwidth points available. Users can gain&lt;br&gt;
bandwidth points from freezing TRX, while 5000 free bandwidth points are also available daily.&lt;/p&gt;

&lt;p&gt;When a TRX transaction is broadcast, it is transmitted and stored in the form of a byte array over the network. Bandwidth Points consumed by one transaction = number of transaction bytes multiplied by bandwidth points rate. For example, if the byte array length of a transaction is 200,then the transaction consumes 200 bandwidth points. However, if a TRX or token transfer results in the target account being created, then only the bandwidth points consumed to create the account will be deducted, and additional bandwidth points will not be deducted. In an account creation scenario, the network will first consume the bandwidth points that the transaction initiator gained from freezing TRX. If this amount is insufficient, then the network consumes the transaction initiator’s TRX. In standard TRX transfer scenarios from one TRX account to another, the network first consumes the bandwidth points gained by the transaction initiator for freezing TRX. If that is insufficient, it then consumes from the free 5000 daily bandwidth points. If that is still not enough, then the network consumes the TRX of the transaction initiator. The amount is calculated by the number of bytes in the transaction multiplied by 10 SUN. Thus, for most TRX holders who may not necessarily freeze their TRX to participate in SR voting, the first step is automatically skipped (since TRX balance frozen = 0) and the 5000 daily free bandwidth powers the transaction.&lt;/p&gt;

&lt;p&gt;For TRC-10 token transfers, the network first verifies whether the total free bandwidth points of the issued token asset are sufficient. If not, the bandwidth points obtained from freezing TRX are consumed. If there is still not enough bandwidth points, then it consumes the TRX of the transaction initiator.&lt;/p&gt;

&lt;h1&gt;
  
  
  TRON Virtual Machine (TVM)
&lt;/h1&gt;

&lt;p&gt;The TVM is a lightweight, Turing complete virtual machine developed for TRON’s ecosystem. The&lt;br&gt;
TVM connects seamlessly with the existing development ecosystem to provide millions of global&lt;br&gt;
developers with a custom-built blockchain system that is efficient, convenient, stable, secure, and&lt;br&gt;
scalable.&lt;/p&gt;

&lt;p&gt;Cheers !!&lt;br&gt;
Axat Bhardwaj&lt;br&gt;
Blockchain Developer &amp;amp; Technologist&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>tron</category>
      <category>web3</category>
    </item>
    <item>
      <title>How to set up Go Ethereum (Geth) private Network/Blockchain and deploy a Smart contract on it (2021)</title>
      <dc:creator>Axat Bhardwaj</dc:creator>
      <pubDate>Mon, 09 May 2022 19:50:17 +0000</pubDate>
      <link>https://dev.to/axatbhardwaj/how-to-set-up-go-ethereum-geth-private-networkblockchain-and-deploy-a-smart-contract-on-it-2021-3199</link>
      <guid>https://dev.to/axatbhardwaj/how-to-set-up-go-ethereum-geth-private-networkblockchain-and-deploy-a-smart-contract-on-it-2021-3199</guid>
      <description>&lt;h2&gt;
  
  
  I'll divide the process in 10 steps :-
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install geth&lt;/li&gt;
&lt;li&gt;Configure the Genesis block&lt;/li&gt;
&lt;li&gt;Create local nodes&lt;/li&gt;
&lt;li&gt;Generate initial accounts&lt;/li&gt;
&lt;li&gt;Initialize and start the nodes&lt;/li&gt;
&lt;li&gt;Connect to each node from the command line&lt;/li&gt;
&lt;li&gt;Interconnect the nodes&lt;/li&gt;
&lt;li&gt;Send some Ether&lt;/li&gt;
&lt;li&gt;Start a miner&lt;/li&gt;
&lt;li&gt;Deploy a Smart Contract&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;here we go …!&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install geth
&lt;/h3&gt;

&lt;p&gt;geth is the command-line interface for running a full Ethereum node implemented in Go. To install it on a Mac, run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install ethereum
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Configure the Genesis block
&lt;/h3&gt;

&lt;p&gt;Next, we need to create a JSON file that will define how the first block of the blockchain will be created. Each node in the network must be initialized with the same genesis block.&lt;br&gt;
Create a file called genesis.json and save it in the parent folder of the nodes directories. Copy the content below but replace the addresses with those of the accounts created in the 3rd step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "nonce": "0x0000000000000042",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x00",
    "gasLimit": "0x8000000",
    "difficulty": "0x400",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",
    "alloc": {
        "0x15024A50E641Ad330e0096bDca8Ea06f9f972Dcd": { //acc1 add it can be diff in ur case
            "balance": "1000000000000000000"
        },
        "0xE3F2Defe3e3DDB4694a985bA6AA052Ad888BCF3D": { //acc2 add it can be diff in ur case
            "balance": "2000000000000000000"
        }
    },
    "config": {
        "chainId": 111,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip150Block": 0,
        "eip158Block": 0
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The config section ensures that certain protocol upgrades are immediately available. The alloc section pre-funds accounts.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create local nodes
&lt;/h3&gt;

&lt;p&gt;For the purpose of this private blockchain, we will create some nodes locally in our machine.&lt;br&gt;
Create 3 new directories. Each of them will represent a single node in the blockchain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ mkdir geth
 $ cd geth
 $ mkdir pvtchain
 $ cd pvtchain
 $ mkdir node01 node02 node03
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Generate initial accounts
&lt;/h3&gt;

&lt;p&gt;Let's create 2 Ethereum accounts in the first node so that later we can do some transactions for testing purposes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ geth --datadir "/PATH_TO_NODE01/" account new
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be prompted for a secret password. Write down the address of the created accounts and memorize the password.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Initialize and start the nodes
&lt;/h3&gt;

&lt;p&gt;The first step is to initialize each node with the genesis file previously created. For this, run this command for each of the nodes, replacing it with the correct path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ geth --datadir "/PATH_TO_NODE/" init /PATH_TO/genesis.json
Then start each node by running the following command for each of them. You will need to use different numbers both for the port and the rpcport.
$ geth --identity "node1" --http  --http.port "8000" --http.corsdomain "*" --datadir "/home/ubuntu/geth/pvtchain/node1" --port "30303" --nodiscover --http.api "db,eth,net,web3,personal,miner,admin" --networkid 1234 --nat "any" --allow-insecure-unlock
$ geth --identity "node2" --http  --http.port "8001" --http.corsdomain "*" --datadir "/home/ubuntu/geth/pvtchain/node2" --port "30304" --nodiscover --http.api "db,eth,net,web3,personal,miner,admin" --networkid 1234 --nat "any" --allow-insecure-unlock
$ geth --identity "node3" --http  --http.port "8002" --http.corsdomain "*" --datadir "/home/ubuntu/geth/pvtchain/node3" --port "30305" --nodiscover --http.api "db,eth,net,web3,personal,miner,admin" --networkid 1234 --nat "any" --allow-insecure-unlock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 pls remember "/home/ubuntu/geth/pvtchain/node1 is my path to node directory&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  6. Connect to each node from the command line
&lt;/h3&gt;

&lt;p&gt;In order to interact with the nodes, you need to open a terminal and use geth to attach to it. Run the following command for each of the nodes, in a separate terminal and use the correct port number for each of them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ geth attach &amp;lt;http://127.0.0.1:8000&amp;gt;
$ geth attach &amp;lt;http://127.0.0.1:8001&amp;gt;
$ geth attach &amp;lt;http://127.0.0.1:8002&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Interconnect the nodes
&lt;/h3&gt;

&lt;p&gt;The first node will be our admin node. Run the following command in the console to read some characteristics about it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; admin.nodeInfo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the enode address completely:&lt;br&gt;
enode: "enode://26f7b83...ed769122f1692e@[::]:30303?discport=0"&lt;br&gt;
Now you can connect the other nodes to this one by running the following command in their respective terminals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; admin.addPeer("enode://26f7b8...92e@[::]:30303?discport=0")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can verify that the nodes are peering by entering the following command in the terminal corresponding to the admin node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; net.peerCount
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. Send some Ether
&lt;/h3&gt;

&lt;p&gt;Next, we will execute a transaction. Go to the console attached to the first node and run the following command to check that you can see the accounts created before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; eth.accounts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then check the balance of the first account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; eth.getBalance(eth.accounts[0])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now unlock the first account in order to start a transaction from it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; personal.unlockAccount(eth.accounts[0])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now send some Ether:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:1000})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. Start a miner
&lt;/h3&gt;

&lt;p&gt;The first thing to do is to set up an account to receive the mining awards. This is called the etherbase account. We will use the admin node as a miner. Go to the console attached to it and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; miner.setEtherbase(eth.accounts[0])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; miner.start()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a null message in the console, and then in the other console where you started the node, you should see the progress of the mining that you just started.&lt;br&gt;
You can now verify the balance of the account and check that the transfer was done properly.&lt;/p&gt;
&lt;h3&gt;
  
  
  10. Deploy a Smart Contract
&lt;/h3&gt;

&lt;p&gt;In this section, we will create and deploy a simple smart contract into our network. For this, we will be using Truffle, which is a development framework for Ethereum.&lt;br&gt;
Run the following command to install the Truffle library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -g truffle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we will initialize a new Truffle project by running this command in a new folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ truffle init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will notice that some initial files and directories were created. We need to modify the truffle-config.js so that Truffle knows how to connect to our network. Use the following content for that file, considering that for the port number you need to use the port where your first node is running, and for the from the address you must complete the address of the first account created in that node:&lt;br&gt;
Next, open the contracts folder and create a new file called hello.sol. Complete it with the following code, which is a simple contract written in the Solidity language:&lt;br&gt;
The next step is to update the migrations file so that Truffle knows that it needs to compile and migrate the contract that we just created. Open the 1_initial_migration.js file located in the migrations folder and modify its content to match the following:&lt;br&gt;
We can now use Truffle to compile our contract and deploy it into our network. Notice that Truffle will also compile and deploy its migrations contract, which is used to track the deployed versions of our contracts and keep them updated.&lt;br&gt;
Go to the contracts folder and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ truffle compile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we need to unlock the account in the first node again, as we are going to deploy the contract using that account. Go to the terminal that is attached to that node and run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; personal.unlockAccount(eth.accounts[0])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, go back to the contracts folder and run this command to deploy the contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ truffle migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The contract should now be deployed in your network at a new address.&lt;br&gt;
The contract is deployed in our network&lt;br&gt;
Cheers !!&lt;/p&gt;

&lt;p&gt;Axat Bhardwaj,&lt;br&gt;
Blockchain Enthusiast &amp;amp; Developer,&lt;br&gt;
Connect with me on LinkedIn: &lt;a href="https://www.linkedin.com/in/axatbhardwaj"&gt;https://www.linkedin.com/in/axatbhardwaj&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
