Reader small image

You're reading from  Blockchain for Enterprise

Product typeBook
Published inSep 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781788479745
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Narayan Prusty
Narayan Prusty
author image
Narayan Prusty

Narayan Prusty is a full-stack developer. He works as a consultant for various start-ups around the world. He has worked on various technologies and programming languages but is very passionate about JavaScript, WordPress, Ethereum, Solr, React, Cordova, MongoDB, and AWS. Apart from consulting for various start-ups, he also runs a blog titled QNimate and a video tutorial site titled QScutter, where he shares information about a lot of the technologies he works on.
Read more about Narayan Prusty

Right arrow

Building the DApp


Let's write the smart contracts for digitalizing fiat currency and storing cell phone numbers linked to bank accounts. Here is the smart contract for digitalizing fiat currency:

pragma solidity ^0.4.18;

contract USD {
    address centralBank;

    mapping (address => uint256) balances;
    uint256 totalDestroyed;
    uint256 totalIssued;

    event usdIssued(uint256 amount, address to);
    event usdDestroyed(uint256 amount, address from);
    event usdTransferred(uint256 amount, address from, address to,
      string description);

    function USD() {
        centralBank = msg.sender;
    }

    function issueUSD(uint256 amount, address to) {
        if(msg.sender == centralBank) {
            balances[to] += amount; 
            totalIssued += amount;
            usdIssued(amount, to);
        }
    }

    function destroyUSD(uint256 amount) {
        balances[msg.sender] -= amount;
        totalDestroyed += amount;
        usdDestroyed(amount, msg.sender);
    }...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Blockchain for Enterprise
Published in: Sep 2018Publisher: PacktISBN-13: 9781788479745

Author (1)

author image
Narayan Prusty

Narayan Prusty is a full-stack developer. He works as a consultant for various start-ups around the world. He has worked on various technologies and programming languages but is very passionate about JavaScript, WordPress, Ethereum, Solr, React, Cordova, MongoDB, and AWS. Apart from consulting for various start-ups, he also runs a blog titled QNimate and a video tutorial site titled QScutter, where he shares information about a lot of the technologies he works on.
Read more about Narayan Prusty