avatarElye

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3786

Abstract

arison operators, and bitwise operators on this type too.</p><p id="c4da">It’s important to note that there is another type, called <code>bytes</code> which is different from the above in that it is a dynamically sized array, and not a value type but a reference type. It is basically shorthand for <code>byte[]</code>.</p><p id="ad39">When you can limit the length of your data to a predefined amount of bytes, it is always good practice to use some of <code>bytes1</code> to <code>bytes32</code> because it is much cheaper.</p><h2 id="0118">Enums</h2><p id="aea7"><b>Enums</b> in Solidity are a way to create user-defined types. Enums are explicitly convertible to integer types, but not implicitly. Enum values are numbered in the order they are defined, starting from 0.</p><p id="ed00">Enums are not part of the ABI (Application Binary Interface — more on this in a later lesson, but it’s basically how you encode Solidity code for the Ethereum Virtual Machine, and how you get data back). This means that if your function returns an <code>enum</code> for example, it will be automatically converted to a <code>uint8</code> behind the scenes. The integer returned is just large enough to hold all enum values. With more values, the size gets increased too (<code>uint16</code> and up).</p><p id="cdb6">The below code, taken from the <a href="https://docs.soliditylang.org/en/v0.4.24/index.html">Solidity docs</a>, defines an enum with four possible values, creates a variable of that enum named <code>choice</code> and a constant called <code>defaultChoice</code>that will hold a default value.</p><div id="cf29"><pre><span class="hljs-keyword">enum</span> <span class="hljs-title class_">ActionChoices</span> { GoLeft, GoRight, GoStraight, SitStill } ActionChoices choice; ActionChoices <span class="hljs-type">constant</span> <span class="hljs-variable">defaultChoice</span> <span class="hljs-operator">=</span> ActionChoices.GoStraight;</pre></div><p id="66a9">Now we can define some functions to interact with our <code>enum</code>.</p><div id="c0bb"><pre><span class="hljs-title function_"><span class="hljs-keyword">function</span> <span class="hljs-title">setGoStraight</span></span>() <span class="hljs-keyword">public</span> { choice = ActionChoices.GoStraight; }

<span class="hljs-title function_"><span class="hljs-keyword">function</span> <span class="hljs-title">setChoice</span></span>(ActionChoices <span class="hljs-keyword">new</span><span class="hljs-type">Choice</span>) <span class="hljs-keyword">public</span> { choice = <span class="hljs-keyword">new</span><span class="hljs-type">Choice</span>; }</pre></div><p id="6bc2">The first one simply sets the <code>choice</code> to <code>GoStraight</code> while the second one sets it to the choice that the caller passes into the function. As we can see after deployment, the <code>setChoice</code> function expects a <code>uint8</code> value, which corresponds to the <code>enum</code> value declared at that number.</p><figure id="e997"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*1pKNPVy4UUBCSLi2-SIckg.png"><figcaption>Testing enums in Remix</figcaption></figure><p id="7917">If we want to get the value of <code>choice</code> and <code>defaultChoice</code>, we can define the following functions:</p><div id="1f02"><pre><span class="hljs-keyword">function</span> <span class="hljs-title">getChoice</span>() public view returns (ActionChoices) { <span class="hljs-keyword">return</span> <span class="hljs-type">choice</span>; }</pre></div><div id="43e7"><pre><span class="hljs-function">function <span class="hljs-title">getDefaultChoice</span>() <span class="hljs-keyword">public</span> pure <span class="hljs-title">returns</span> (<span class="hljs-params"><span class=

Options

"hljs-built_in">uint</span></span>)</span> { <span class="hljs-keyword">return</span> <span class="hljs-built_in">uint</span>(defaultChoice); }</pre></div><p id="c2f2">As we can see if we try this out in Remix, the first function returns a <code>uint8</code> while the second returns a <code>uint256</code>.</p><figure id="e514"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*jmaOFb9GhXz7FWC4ONMa_A.png"><figcaption>Testing enums in Remix</figcaption></figure><h2 id="3c7c">Fixed point numbers</h2><p id="2ecc"><b>Fixed point numbers </b>represent fractional numbers by storing a fixed number of digits of their fractional part. No matter how large or small the fractional part is, it will always use the same number of bits.</p><p id="cdcd" type="7">Fixed point numbers are not fully supported by Solidity yet. They can be declared, but cannot be assigned to or from.</p><p id="f872">We can differentiate between signed fixed point numbers, declared with the <code>fixed</code> keyword, and unsigned fixed point numbers, declared with the <code>ufixed</code> keyword.</p><p id="3c1c">It can also be declared as <code>fixedMxN</code> or <code>ufixedMxN</code> where <code>M</code> represents the number of bits the type takes, and <code>N</code> represents the number of decimal points. <code>M</code> has to be divisible by 8 and a number between 8 and 256. <code>N</code> has to be a number between 0 and 80.</p><p id="96e1">They function with the following operators:</p><ul><li>Comparisons: <code><=</code>, <code><</code>, <code>==</code>, <code>!=</code>, <code>>=</code>, <code>></code> (evaluate to <code>bool</code>)</li><li>Arithmetic operators: <code>+</code>, <code>-</code>, unary <code>-</code>, unary <code>+</code>, <code>*</code>, <code>/</code>, <code>%</code> (remainder)</li></ul><h2 id="09b7">Conclusion</h2><p id="bd3a">In this lesson, we looked at what value types are available in Solidity and how each one works.</p><p id="28de">Thank you for staying with us till the end. If you enjoyed reading this piece please keep in touch and follow Solidify to keep up with our lessons on Solidity. In the upcoming articles, we will deep dive into the intricacies of the language, progressing from beginner to advanced level.</p><p id="067c">If you are new to Solidity, check out the previous lessons about setting up a local development environment and writing your first smart contract.</p><div id="6b76" class="link-block"> <a href="https://readmedium.com/how-to-setup-your-local-solidity-development-environment-c4c8195810f3"> <div> <div> <h2>How to Setup Your Local Solidity Development Environment</h2> <div><h3>Get started with smart contract development</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*HHko-o9m1sVngmTeRVYgKA.jpeg)"></div> </div> </div> </a> </div><div id="3ad1" class="link-block"> <a href="https://readmedium.com/lesson-1-your-first-solidity-smart-contract-1ba7e641f9a3"> <div> <div> <h2>Lesson 1: Your First Solidity Smart Contract</h2> <div><h3>In the previous lesson, we looked at how to set up your local Solidity development environment. Here we will continue…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*7r7HSYkbn73NrmR_skvh5w.jpeg)"></div> </div> </div> </a> </div></article></body>

Aid for Medium Writers

Seven insights from a medium article stat page

Experiment to increase audience and earnings for an article

Photo by Rohan Makhecha on Unsplash

When you write on Medium and join the Medium Partner Program, each of your articles will be given a detailed statistic of how it performs.

But like all data, it doesn’t just tell you how you perform as it is, but also some great insights into what works best for you.

Below is one of my article statistics across a span of 9 days, which multiple promotion activities for the article as stated under the graphs. From it, I get various insights

Graphic provided by Author

1Initial promotional will generate great views for your article. When I published my article, I also promote it on Facebook, Twitter, etc. Together with my followers, that allows me to generate quite a bit of view, which is in fact my top views so far for the article.

Lesson: Don’t just publish your article without further promoting it. Just relying on Medium to help promote to your followers will not generate good views count. Do note: this article got curated (i.e. distributed) and it is still not generating as many reads as one could promote through external social media.

2Not all your followers will view your articles, at least on the first day. I have almost 5200 followers, but on the first day, less than 1500 people views. That already includes external promotions that have people who are not my followers that might have viewed the article as well. In fact for the span of 9 days, only about 3500 viewers so far.

Lesson: Firstly not all your followers are interested in all the articles you wrote. They might follow you due to some topics you wrote about. Some followers follow too many people, hence your article might drown in many other articles, and never be seen by those followers. Never stop getting recruiting more followers and getting a wider audience.

Note: even though I have 5000+ followers, I only have about slightly above 15% of followers are Medium members. Below is the way I use to extract the info.

3 Top view count doesn’t guarantee top-earning. As you could see lots of my article views on the first day are in light blue color. That’s External Views. Although External Views doesn’t always mean it is not Medium Member, it is more likely they are not than they are.

Lesson: That’s the reason I really hesitate to use any pay mechanism externally to promote my article, as the return would be negative.

4Publish in Medium’s Publication will generate better members' read. In other words, it will generate better earnings. I manage to get my article into a relatively established publication on Medium, and the earnings top the chart. It is not always the case, but it’s definitely effective, especially if you wrote an article that fits the reputable publication audience.

Learning: If you are new to Medium writing, trying to get the writer right to some publication should be your first aim. If you wrote in various genres, then you need to aim for a different publication, to be effectively relevant. Check the below to get insight into Medium Publications.

5External promotion could still contribute to more members reading. Even though external promotion might not be as effective as your article published on a publication within Medium, it is still helping you to generate more members to read. This is proven from my stat above, where when my article is promoted through another email channel by an external publisher at a later time of the week, the member reads and earnings also increase.

Lesson: Don’t despite the external promotion of your articles. I personally share friends-links out so that we get more readers to your articles, from time to time. I write so that others could read. Earning is just a by-product, and shouldn’t be the main. Earning should just be the fuel for us to write on. Earnings will grow as we share more.

6 Continuous promotion of your articles is crucial. I could imagine if I just publish my article after I wrote it, and maybe promote it the first day only, then I leave it there organically growing. It might grow if it hit someone interested. But more likely it will slowly fade off, and become irrelevant soon.

Lesson: An article is just a diary if it is not shared with enough audience. Hoping for the natural organic growth of your articles is most of the time like wishful thinking. Some marketing work is required to promote it to the relevant channels and to reach its targeted audience that would benefit from it.

7 Reading time is not always correlated with earning. As you could see from the graph, the top reading time doesn’t align with the top earning. Although they are fairly correlated, that is not always true. It is based on the reading time of the members normalize with the total reading time on all other articles. You’ll earn less from members that read a lot of articles.

Lesson: Imagine if a follower just reads your articles, and you write ten articles and the follower reads all of them. Next month, you write twenty articles, and he reads all of them. The earnings you’ll get from the followers most likely going to be the same for both months. That’s the reason you need to get more followers and other members to read your articles.

I hope my experiment and insights learning is helpful to set better expectation and what possibly could be done tactically to improve readability and earning. Nonetheless, most important is still the article itself, which should focus on bringing value to its audience. Wishing you the best in your writing journey!

To get more insights from other statistics from Medium Dashboard, shown below is some analysis of my 4 years of writing.

Thanks for reading. You can check out my other topics here.

You could follow me on Medium, Twitter, Facebook, or Reddit for little tips and learning on mobile development, medium writing, etc related topics. ~Elye~

Marketing
Writing
Blog
Entrepreneurship
Self Improvement
Recommended from ReadMedium