Posts

Rust Basics for programming

Rust is not a particularly original language. Its design elements came from a wide range of sources.  ▸ Abstract Machine Model : C  ▸ Data types : C, SML, OCaml, Lisp, Limbo  ▸ Optional Bindings : Swift  ▸ Hygienic Macros : Scheme  ▸ Functional Programming : Haskell, OCaml, F#  ▸ Attributes : ECMA-335  ▸ Memory Model and Memory Management : C++, ML Kit, Cyclone  ▸ Type Classes : Haskell  ▸ Crate : Assembly in the ECMA-335 CLI model  ▸ Channels and Concurrency : Newsqueak, Alef, Limbo  ▸ Message passing and Thread failure : Erlang Rust files should have .rs file extension and if you’re using more than one word for the file name, use lower case and separate words with an underscore (snake_case) To Compile rustc file.rs Cargo is Rust’s build-in Package Manager. But mainly it uses for,  ▸ Create new project : cargo new  ▸ Update dependencies : cargo update  ▸ Build project : cargo build  ▸ ...

Always Moving Forward with Rust/Parity

It been a while since my last post mainly cause ive been implementing alot of DApps and refining my skills on Solidity. But ethereum is not all about Solidity. In my first first few posts , i mentioned the technologies i was using. mainly Geth, for running ethereum nodes. However Geth is alot slower and much better implementations are now available that makes use of different languages. This post is me moving forward to Parity . Parity is an Ethereum client, written from the ground-up for correctness-verifiability, modularisation, low-footprint and high-performance. To this end it utilises the Rust language, a hybrid imperative/OO/functional language with an emphasis on efficiency. So let the learning begin. First Environment. Ive tried installing on Mac/Windows/Linux. at some point i want to be adding or developing for Parity (apparently a good market for developers). Im going to Opt for an Ubuntu environment. Rust programming language Rust  is a systems progra...

"Building Security" Solidity Example

Solidity contract to track Building Entries pragma solidity ^0.4.0; contract BuildingSecurity { struct Visitor { string name; string information; string VisitorID; uint8 ID; string fbID; string opencv; address delegate; } //visitor structure for name and information struct TempVisitor{ string name; string id; } Visitor[] EmployeePermanent; //list of permanent entries enum State { ENTRY, EXIT, IN, NON } //building state for visitors struct BuildingDoors { string DoorName; string fullname; string cardnumber; } State public state = State.NON; // initialize on create address buildName; string buildingNameDisplay; mapping(address => TempVisitor) visitors; BuildingDoors[] AllDoors; function BuildingSecurity(uint8 _numEntryLimit, string _buildingDisplay) public { buildName = msg.sender; ...

"ICO Contract" Example (Send Token in Exchange for Ether)

In this post i can send Ether to the Creator Account as a donation from another Account Ive also created a Token Contract where you can s end Tokens to Another Account In this post, i will make use of both concepts with the following assumption: I have a company and i would like to go ICO. Initial coin offering  ( ICO ) is an unregulated and controversial means of crowdfunding via use of cryptocurrency, which can be a source of capital for startup  companies . So if someone or a company wants to help me setup my company and get some Initial Coins. My initial Coins are Tokens and i accept Ether in exchange for the Token. So the process goes as follows. 1. I Deploy my TOKEN contract with an initial of 1000 2. Another Account will send me Ether and i will send back some Coins. 3. My Exchange Rate is 1 to 1. So for Every Ether, i will send 1 Token back to the person who gave me Ether. In the Code below, i am giving 7 Tokens for any amount pragma solidity ^0....

Crypto-Currency "Coin Contract" Example

Image
So here is my starting point pragma solidity ^0.4.18; //Used like an Interface in C# or Java contract Token { function totalSupply() public constant returns (uint256 supply) {} function balanceOf(address _owner) public constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) public returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {} function approve(address _spender, uint256 _value) public returns (bool success) {} function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {} //needed to Log the Events event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { mapping (address => uint256) balances; mapping (address => mapping (address => uint25...

Blockchain IoT Example "Iris Contract"

In this post i will be creating a contract that works with a device (a device that can acquire your IRIS (EYE) Data and use it for Unlocking or Security. How is it an IoT? Source The  Internet of things  ( IoT ) is the network of physical devices, vehicles, home appliances, and other items  embedded  with  electronics ,  software ,  sensors ,  actuators , and  network connectivity  which enable these objects to connect and exchange  data . There are many Cheap Hardware devices currently in the market that can provide and Iris Code. One of these devices is the Samsung Note 7 that has a built in Iris Scanner for Unlocking Phone as a Secondary Authentication   Source So assuming i have the hardware that can get My Iris Scanned. What will be the output of this Hardware? How do iris Scan work?  identifies around 240 unique features (about five times more "points of comparison" as fingerprint systems use). The...

Blockchain Business Example "Smart Property Contract"

This contract is for tangible and intangible property such as Cars, Houses or Patents. Can be used to record and verify property rights. First,  payable  is a modifier that can be added to a function. It's impossible to have  payable()  as a function name as it is a reserved keyword. You may use  payable  only in addition to existing functions  Second,  Payable  allows a function to receive ether while being called as stated in  docs .It's manadatory from solidity 0.4.x. If you try to send ether using  call pragma solidity ^0.4.18; contract LandAresh { address public owner; uint public defaultCost; uint public mainLandCost; mapping(uint => mapping(uint => address))public properties; mapping(uint => mapping(uint => address))public landContent; mapping(uint => mapping(uint => bool))public status; mapping(uint => mapping(uint => uint))public prices; funct...