April 15, 2026

Capitalizations Index – B ∞/21M

Part Eight – Technology@Nineleaps

Part Eight – Technology@Nineleaps

Building the First Token

Blockchain Revolution Part 8

The seventh post of the series talked about smart contracts and ways to deploy them. In this last article we will create our own cryptocurrency. To do so I have reused the same contract we created last time MyToken as shown below and further added to it.

pragma solidity ^0.4.20;
contract MyToken 
function _transferFunds(address _from, address _to, 
uint value)
}

The function _transferFunds() sends an amount from one account to another.

All the DApps are decentralized however some may require a manager to perform certain operations such as adding more coins, restricting some users from using your currency. So, let’s create a manager.

Create another contract Owned

contract Owned 
modifier onlyOwner() 
function transferOwnership(address newOwner) onlyOwner public 
}

Add a state variable owner of type address. Then add a modifier onlyOwner() to tweak the functionality. It is much like checking a condition, before function is executed. Inside the modifier check if the sender address belongs to owner or not. If the address belongs to the owner then only the function in which the modifier is called will be executed.

modifier onlyOwner() 

Next step will be to make a function for transferring ownership to another address. Create a function transferOwnership() with the address of new owner and add the modifier to it so that only the owner can execute this operation.

function transferOwnership(address newOwner) onlyOwner public 

Now let’s go back to the contract MyToken.sol where we will add more features for the token.

Inherit the contract Owned to MyToken using the is keyword.

contract MyToken is Owned 

This means that now all the functions inside MyToken can call variable owner and modifier onlyOwner(). This is how inheritance is performed in solidity.

Now, let’s assume you wish to restrict some people from using their tokens. For this we can add a parameter that authorizes contract owner to freeze and unfreeze some accounts. Freezing of accounts means that no transactions can happen from and to that account.

To enable this you need to create a mapping and add an event FrozenFunds().

mapping (address => bool) public frozenAccount;
event FrozenFunds(address targetAccount, bool freeze);

Events are like signals that the contracts generate and anything connected to the blockchain listen to these events and act accordingly.

Next add a function freezeAccounts() where the target address to be frozen is specified.

function freezeAccount(address targetAccount, bool freeze) 
onlyOwner public

Within the function, using a map, set the address of the target account to freeze value true. Only the owner of the contract should be authorized to freeze account and that’s why modifier onlyOwner is added. After setting the bool value of mapping to true, emit the event FrozenAccount().

Now in the _transferFunds() function, check if the account is frozen before making the transaction. It should look like this:

function _transferFunds(address _from, address _to, uint value) internal 

Both from and to addresses should be unfrozen for the transaction to occur. Now let’s consider you gave another address access to transfer funds on your behalf and you want to set a limitation on how much the user can send on your behalf. For this we need to create another method approve() and a mapping allowance as shown below:

mapping (address => mapping (address => uint)) public allowance;
function approve(address _spender, uint _value) public 
returns (bool success)

We create a map within a map. Solidity provides a feature to specify the return type in the function. The return type specified here is boolean. _spender is the address which is authorized to execute transactions on our behalf and _value is the max transfer limit. We are setting the spending limit to _value for the _spender within the function and returning true.

Now let’s create another function transfer() which will check all the above conditions before making any transaction.

function transfer(address _from, address _to, uint value) public returns (bool success) 

In this scenario, we will first check if the sender is authorized to make a transaction by checking the allowance of that sender. If the allowance limit is more than the amount being send, then transaction can be made. If the condition is satisfied, then function _transferFunds() is called where remaining conditions are checked. If everything is fine, then the function returns true and the transaction occurs.

Now we have to deploy it to the test network. For which we create a file 2_deployment_mytoken.js in the folder migrations. After creating the file, add the following lines to it. Here we are setting the constructor values for the MyToken contract we created before.

var mytoken = artifacts.require("./MyToken.sol");
module.exports = (deployer) => 

And that’s it. Deploy it to the test network and you have your own token.

For the complete code, checkout the github link here.

The promise of Blockchain in a digital world

With this we conclude our series ‘Blockchain Revolution’. We have listed all the articles at the end of this post, in case you missed any of them or like to revisit.

While this series may have come to an end, blockchain technology has only just begun. With blockchain evolving from merely supporting cryptocurrency to being used as business applications, we are already starting to witness its value. Although, right now what we are experiencing is just the tip of the iceberg. This distributed ledger technology holds staggering potential to impact business, economics and society. We just have to wait and see as it emerges to be the next big frontier.

Published at Fri, 11 Jan 2019 06:48:57 +0000

Previous Article

Binance Competition – Bitcoin [BTC] Giveaway!

Next Article

has perdido la fe en bitcoin [BTC]? entonces mira este video

You might be interested in …

Introducing TL;DR

Blockchain on Medium Introducing TL;DR Hello guys, my name is Sever and I am from the Internet. I read ICO whitepapers and share my understanding. Internet strangers are rarely qualified and honest, so always do […]

Re: Do you see alts have chances against Bitcoins?

Re: Do you see alts have chances against Bitcoins? Advertised sites are not endorsed by the bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here. Moyna Newbie Offline Activity: 1 […]

Global Banking System Under Threat As Hackers Crack NSA, SWIFT Again

Hacker group Shadow Brokers has allegedly proved the US National Security Agency (NSA) hacked SWIFT international banking network.


NSA ‘Documents And Files’ Show SWIFT Transactions ‘Monitored’

In “documents and files” released Friday, Reuters reports, the group said it had evidence the NSA used SWIFT to “monitor money flows among some Middle Eastern and Latin American banks.”

The news marks the second time Shadow Brokers has laid claim to compromising NSA secrets. In August 2016, the group said it had entered an agency affiliate and taken details of cyberweapons, which it planned to auction for one million bitcoins.

If true, it is also a further blow to SWIFT, which last year recorded several high-level security failures worth hundreds of millions of dollars.

“NSA hacked a bunch of banks, oil and investment companies in Palestine, UAE, Kuwait, Qatar, Yemen, more,” Mustafa Al-Bassam, computer science researcher at University College London, commented on the findings.

bitcoin Core Dev: Implications Beyond Spying ‘Burning Question’

Reactions from within the cryptocurrency community meanwhile focussed on the broader implications of Shadow Brokers’ latest attack.

Core developer Wladimir van der Laan wrote on Twitter “(finding) indication of tools for manipulation of banks/markets, more than spying” was now the “burning question.”

//platform.twitter.com/widgets.js

As the traditional financial system comes under increasing threat from cyber criminals, bitcoin could emerge as the go-to method for storing wealth thanks to its decentralized blockchain and SHA 256 encryption, especially when compared to the ‘honeypot’ of banks’ centralized databases.

Microsoft Back In Spying Spotlight

The released data does not only focus on SWIFT, but also on Microsoft. Having been outed as involved in NSA spying activities by Wikileaks’ Vault 7 dump in March, the corporation this time is facing stolen code for compromising Windows, “at least some of which still work.”

In a responsorial statement, Microsoft protested ignorance. No official correspondence regarding the threat had been received.

“Other than reporters, no individual or organization has contacted us in relation to the materials released by Shadow Brokers,” it told Reuters.

Windows 10

Regarding the specifics of the SWIFT hack, it appears Dubai-headquarted service bureau Eastnets could be a major target.

Like Microsoft, the SWIFT intermediary denied any malicious activity had occurred.

The reports of an alleged hacker-compromised EastNets Service Bureau network is totally false and unfounded,” the BBC quotes a spokesperson as saying. “The EastNets Network Internal Security Unit has run a complete check of its servers and found no hacker compromise or any vulnerabilities.”

NSA spying activities are claimed to have affected not just companies, but politicians and even everyday consumers.

As part of Vault 7, WikiLeaks suggested end-user electronic devices such as smartphones and smart TVs could have become microphones for intelligence officers to listen in on.

Even Donald Trump and his family may have fallen victim.

What do you think about the Shadow Brokers’ latest claims? Let us know in the comments below!


Images courtesy of Swift, Twitter, Shutterstock

The post Global Banking System Under Threat As Hackers Crack NSA, SWIFT Again appeared first on Bitcoinist.com.