MENU

Understanding basic functions in solidity

December 22, 2018
0
7509
0
Smart contracts are comprised mainly of functions so it is important to understand how to construct one and all the various options available. From the solidity documentation, the syntax of a function is as follows: function FunctionName([parameters]) {public|private|internal|external} [pure|constant|view|payable] [modifiers] [returns (<return types>)] What this means is that when creating a function, here are the required steps. Use the function keyword Provide a function name Provide parameters if required Set the function’s visibility. There’s 4 options to choose from. public, private, internal, or external: Set the behaviour of the function. Choose from view, pure, or payable. Add any applicable modifiers Add any applicable return types/parameters Here is a brief explanation of the different visibilities. Public: All (contracts can a call the function) Private: Only this contract Internal – only this contract and contracts deriving from it External – Cannot be accessed internally, only externally. Private is a subset of internal and external is a subset of public. For a more detailed and intriguing analysis of the difference between public and external check this. (TLDR: public uses more gas because it uses memory instead of calldata). (Check the docs for more details). The behaviours are defined as: View: Can read the state but will not modify storage state […]
Read More ›

What does semantic versioning have to do with Solidity

December 17, 2018
0
6410
0
Considering that the very first line of a solidity smart contract is something like: pragma solidity ^0.4.21 What does the caret really mean? The short answer is the caret or top hat (^) means the code will be compatible with compiler version from 0.4.21 to 0.5.0. This sounds easy to understand but it doesn’t actually tell the whole story. To really understand it, means learning about the concept of Semantic Versioning. In short, software versioning generally follows the format major.minor.revision. The caret is only one symbol out of various others such as ~ (tilde), * (wild card), || (logical or) and a bunch of typical ones such as >, >=, < and <=. The real definition of ^ is: “Allows changes that do not modify the left-most non-zero digit in the major.minor.version tuple format.“  This definition explains the following examples: ^1.2.3:  >=1.2.3 and <2.0.0 ^0.2.3: >=0.2.3 and <0.3.0 ^0.0.3: >=0.0.3 and <0.0.4 Tilde is interesting. The definition is: “Allows patch-level changes if a minor version is specified on the comparator. Allows minor-level changes if not.” which again is explained by these examples: ~1.2.3:  >=1.2.3 and <1.3.0 ~0.2.3: >=0.2.3 and <0.3.0 ~1.2:>=1.2.0 and <1.3.0 (Same as 1.2.x) ~1: >=1.0.0 <2.0.0 (Same as […]
Read More ›

Great resources for learning about NEO

March 9, 2018
0
5663
0
Here are some great links to learn about NEO. The analogies are very good. https://steemit.com/cryptocurrency/@basiccrypto/almost-everything-you-wanted-to-know-about-neo-part-1-of-2 https://steemit.com/cryptocurrency/@basiccrypto/almost-everything-you-wanted-to-know-about-neo-part-2-of-2 https://steemit.com/neo/@basiccrypto/neo-s-consensus-protocol-how-delegated-byzantine-fault-tolerance-works
Read More ›

What are smart contracts?

March 18, 2017
0
2983
0
Simply stated, A smart contract is some software code that transfers assets between parties when certain conditions occur. That is a very simple explanation but let’s dive deeper into what it really means, what it looks like and how it works. What it means? Smart contracts were brought to light in the mid 90’s and cryptographer Nick Szabo is generally credited with “inventing” smart contracts. The reason it has gained significant momentum now is because of the invention of bitcoins, the most successful digital currency to date and the underlying framework it provides. In a sentence, contracts are agreements between parties. Smart contracts are agreements between parties in the digital realm. A more formal definition of a smart contract is: a computer program that directly controls the transfer of digital currencies or assets between parties under certain conditions. It not only defines the rules and penalties around an agreement in the same way that a traditional contract does, but it can also automatically enforce those obligations. It does this by taking in information as input, assigning value to that input through the rules set out in the contract, and executing the actions required by those contractual clauses. These contracts are […]
Read More ›

Ian Grigg: Ricardian Contracts And Digital Assets Prehistory

March 8, 2017
0
4113
0
Ian Grigg: Ricardian Contracts And Digital Assets Prehistory A neat and very informative podcast on the history of digi cash, financial cryptography and Ricardian contracts. The history was fascinating because it provides a lot of context to how we got to where we are today. It’s a little lengthy but definitely worth a watch.
Read More ›