Home Cryptocurrency How to Launch Your Own Cryptocurrency

How to Launch Your Own Cryptocurrency

cryptocurrency

Share This On Social

How to Launch Your Own Cryptocurrency

The way we handle money is quickly changing. The question is, “How can you keep up?” Even though the revolutionary cryptocurrencies and the blockchain technology have existed for several years, it’s only over the past few months that the conversation has stepped out of tech company boardrooms and internet forums.

Perhaps it’s your time to come up with the next cryptocurrency or to create trade channels through which people can exchange products and services. Though it sounds complicated, it’s actually quite simple. This is all credited to the big steps that have been made by the community and the great innovations they have come up with.

ethereum

 

Bank of the Future

Today’s banks are no doubt being replaced by cryptocurrency. Banks operate by keeping track of your account. This is just an institution keeping track of your money. With cryptocurrency, however, your money is visible to anyone and everyone on the network. Unlike in banks, your trust lies on a huge computer network. All the computers in the system confirm every transaction, and that will ever happen. People depend on this public ledger when you use crypto as a means of payment.

Your cryptocurrency can become the token that you choose to accept for business. This currency can start working today. You will first need to select a huge computer network that’s always confirming that new additions are legit and should be decentralized. Let’s go with Ethereum.

token

Contract Programming

Ethereum is a computing platform that executes smart contracts and is decentralized. There’s no possibility of tampering by third parties since these programs run on complete transparency. For each request that results in the execution of a smart contract, a unique signature is created using a user’s private key.

The Ethereum community enjoys a huge following of software engineers who consistently develop amazing tools that will make our lives easier.

You will need the following four tools to create new crypto successfully:

  • Solidity – This is a programming language used to create smart contracts. It’s specific to Ethereum.
  • Truffle Framework – It’s a development kit for Ethereum.
  • Web3.js – It’s a JavaScript language that interacts with the Ethereum network.
  • Ether – The currency used on the Ethereum network.

Alternative tools:

  • MetaMask – A crypto payments extension by Chrome.

Blockchain has a limitless number of uses; cryptocurrency is just one among the many. Investing your time to build decentralized apps on the Ethereum network is made attractive by the bright community surrounding Solidity. To start learning all about blockchain developments, you should first create your own cryptocurrency.

ERC-20 Token Development

On the topics of smart contract functionality and tokens, some standards have been established by the Ethereum community. The standard of the ERC-20 token has been used here for our cryptocurrency token.

Install node.js and make sure that it’s the latest version.

Open a terminal window and type in the following:

npm install -g truffle

mkdir MyToken && cd MyToken

truffle init

npm init -y

npm install -E zeppelin-solidity

This code will create a project directory for the token and install the truffle CLI. It will also install OpenZeppelin, which is a solidity library that’s open source.

We can now start working on our Solidarity contract. You should understand Solidity and the dangers observed in the Token Standard. Create a file named Token.sol in the auto-generated contracts folder. This folder should be in the project directory.

The following code is compliant with the specifications of the ERC-20 Token Standard.

Pragma solidity ^0.4.18;

import ‘zeppelin-solidity/contracts/math/SafeMath.sol’;

/**
* Token
*
* @title A fixed supply ERC20 token contract.
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
*/
contract Token {
using SafeMath for uint;

event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);

event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);

string public symbol;
string public name;
uint8 public decimals;
uint public totalSupply;

mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;

/**
* Constructs the Token contract and gives all of the supply to the address
* that deployed it. The fixed supply is 1 billion tokens with up to 18
* decimal places.
*/
function Token() public {
symbol = ‘TOK’;
name = ‘Token’;
decimals = 18;
totalSupply = 1000000000 * 10**uint(decimals);
balances[msg.sender] = totalSupply;
Transfer(address(0), msg.sender, totalSupply);
}

/**
* @dev Fallback function
*/
function() public payable { revert(); }

/**
* Gets the token balance of any wallet.
* @param _owner Wallet address of the returned token balance.
* @return The balance of tokens in the wallet.
*/
function balanceOf(address _owner)
public
constant
returns (uint balance)
{
return balances[_owner];
}

/**
* Transfers tokens from the sender’s wallet to the specified `_to` wallet.
* @param _to Address of the transfer’s recipient.
* @param _value Number of tokens to transfer.
* @return True if the transfer succeeded, false if not.
*/
function transfer(address _to, uint _value) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}

/**
* Transfer tokens from any wallet to the `_to` wallet. This only works if
* the `_from` wallet has already allocated tokens for the caller keyset
* using `approve.` From wallet must have sufficient balance to
* transfer. The caller must have sufficient allowance to transfer.
* @param _from Wallet address that tokens are withdrawn from.
* @param _to Wallet address that tokens are deposited to.
* @param _value Number of tokens transacted.
* @return True if the transfer succeeded, false if not.
*/
function transferFrom(address _from, address _to, uint _value)
public
returns (bool success)
{
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(_from, _to, _value);
return true;
}

/**
* Sender allows another wallet to `transferFrom` tokens from their wallet.
* @param _spender Address of `transferFrom` recipient.
* @param _value Number of tokens to `transferFrom`.
* @return True if the approval succeeded, false if not.
*/
function approve(address _spender, uint _value)
public
returns (bool success)
{
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}

/**
* Gets the number of tokens that a `_owner` has approved for a _spender
* to `transferFrom.`
* @param _owner Wallet address that tokens can be withdrawn from.
* @param _spender Wallet address that tokens can be deposited to.
* @return The number of tokens allowed to be transferred.
*/
function allowance(address _owner, address _spender)
public
constant
returns (uint remaining)
{
return allowed[_owner][_spender];
}
}

There’s a fixed supply of this token and is not mineable. There are a billion tokens by default. Each one can be broken down into a fraction of 18 decimal places. In Bitcoin, the smallest unit is called a Satoshi while Wei is the smallest unit in Ethereum. You are not limited to any name. You can change them to whatever works for you.

To send or receive the token, you will have to execute the code in the contract once the code has been loaded into the Ethereum network. The information about the owners of the tokens is held in a data structure called the balances map. The public key of the wallet holder is the address. The number of Wei in the wallet is determined by the 256-bit integer.

Cryptocurrency

Read vs. Write

For the blockchain, read and write are governed by two easy rules; reads are free while writes are not. In the case of Ethereum network, the caller has to spend ETH when executing blockchain additions. Just like transferring tokens between wallets, functions that change state is the ones that make additions. Read functions include viewing the balance. They are always free, and they don’t add any data to the blockchain.

Deploying

Once you are comfortable with network gas prices, writing some tests and Solidity, it’s time to do a test run. Put your token on a public test network and run it. Ethereum development uses the Ropsten network, among others, for tests. You can configure the network connections in the truffle.js file.

Create an Ethereum wallet if you still don’t have one. This is a must. To create a mnemonic and wallet, use this tool. In the coin dropdown, select ETH. Click the English button. Save the mnemonics in a safe place.

It’s highly advisable to separate the wallets for the test network and the main network. The Ethereum key set mnemonic should be added as ehthereum_mnemonic to the variables in your environment.

Install MetaMask Chrome extension to get test ETH in your wallet. You have to spend some ETH to execute a transaction in your contract.

truffle migrate –network ropsten

The above command logs the contract’s address. Make sure that you save it. Migrate points to the Ropsten key by using the –network flag. The Ropsten object, among others, can also be included in the main Ethereum network. Due to safety reasons, we excluded it from the above Truffle box code. In this Truffle tutorial, you will find a ‘live’ connection object. It’s for the main Ethereum network.

You can check your token balance, once you have deployed your contract by using the MetaMask extension. In the MetaMask user interface, select Ropsten Test Network, and click the tokens tab. Click Add Token. Type in the address of the contract that was logged from the command of the truffle migrate.

Though ICO developers are excited by the above contract, it’s limited in that it’s unable to execute newsworthy crowdsale. Let’s make it happen.

ethereum

Crowdsales

Having installed truffle, written a bit of test code and used the CLI, we can now open up an already existing Truffle project. In our case, the Crowdsalable Ethereum Token.

We will create a new directory and use the Truffle CLI to extract the project from my GitHub repo.

mkdir crowdsalable-eth-token && cd crowdsalable-eth-token

truffle unbox [email protected]:ajb413/crowdsalable-eth-token.git

The implementation of this Truffle project is more robust than of an Ethereum token. The owner can configure the name of the token as well as its symbol once the contract has been deployed. Furthermore, the owner can choose to create and release new crowdsales whenever they feel like it.

The Truffle box can execute contracts on the Ethereum clients since it contains a development mode UI. The Truffle Develop command automatically creates 10 new static wallets on your computer. The UI, in turn, uses these static wallets to launch crowdsales, view wallet balances and execute transfers.

token

Broadcast Crowdsale Announcements

There’s a tiny bit of PubNub magic, and the web user interface in the app/ folder. Once a crowdsale is launched, the owner can choose to send texts to all their followers so that they can start buying your token. The text message should contain all details regarding the crowdsale.

You must first sign up for ClickSend and PubNub to enable this exciting feature. Without these two, this beautiful functionality will not be possible. You will insert your subscription key, API key and publish key in sms-handler.js and app.js. You will also have to choose who receives the text by editing the phone numbers in JavaScript.

Development UI with Web3.js

Just like we did earlier, we will now run the Ethereum client.

cd crowdsalable-eth-token

npm i

truffle develop

## Truffle development blockchain and console are booted

truffle(develop)> compile

truffle(develop)> migrate

truffle(develop)> test

  • Leave the truffle console running
  • Open a new command line window
  • Navigate to the same project directory

Run the development UI with:

npm run dev

> crowdsalable-eth-token dev /crowdsalable-eth-token

> webpack-dev-server

The project will be running at http://localhost:8080/

You can now explore the main features of your browser.

We can:

  • Launch a crowdsale
  • Transfer tokens between wallets
  • Use ETH to purchase tokens from a crowdsale
  • Open any wallet and check the balance