Cultivating Conscious Love in Everyday Life

There are days the beauty of the world (and man’s creations — music, art, literature, etc.) overwhelms me and brings me to tears. I really don’t understand how we can just live like this, destroying…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to create ERC20 Token?

ERC20 Token:

Blockchain is the like tracking technology, its transfer the transaction without third party between nodes with decentralised, distributed ledger, timestamp and immutable data store in blocks.

Its shared ledger for recording the history of transactions — that cannot be altered.

Etherioum is one of the platform in blockchain. Its decentralized platform where application can be built and run on a decentralized network.

Bitcoin does for payment but etherioum does for anything that can be programmed.

In general, a token is an object that represents something else, such as another object (either physical or virtual), or an abstract concept as, for example, a gift is sometimes referred to as a token of the giver’s esteem for the recipient. In computers, there are a number of types of tokens. Token exchange between two points.

Every token has some standards we will see here ERC20 Token(Etherioum Request Command).

Its fungiable token, We used this token for trade, It is a trackeble, It has developed by solidity programing language smartcontract. Deployed in etherioum.

It has to five properties:

These properties indeed question in every etherioum interview.

Total supply():

Every token before initialized set total count of token generation.

uint256 public totalSupply = 10000;

function totalSupply() public view returns(uint256){

return totalSupply;

}

Create the total supply function and return the total supply. Its doesn’t exit count of token generation. It return the generated token.

Balance():

Create function for check the balance amount to the account address. Every account address and balance are storing in balances. Its a mapping method. we pass the address through parameter. it gives address’s balance.

mapping(address=>uint)public balances;

Function balanceOf(address tokenOwner) public view returns(uint256){

return balances[tokenOwner];

}

Transfer():

Transfer is send the value from one address to another address. Every user has address.

They send token exchange between them. Create the transfer function.

from(Token owner address),

to(receiver Token address),

value(token).

Function transfer(address from, address to, uint256 value) public returns(bool success){

balances[from] = balances[from].sub(value);

balances[to] = balances[to].add(value);

emit Transfer(from,to,value);

return true;

}

Two simple steps:

Sender(from address) subtract the value of the balance, Receiver(to address) Add the value of the balance.

Transfer From():

This function current person transfer the amount from another person account.

Function transferFrom(addres from, address to, uint256 value) public returns (bool success){

balances[from] = balances[from] — value;

allowed[from][msg.sender] = allowed[from][msg.sender]-value;

balances[to] = balances[to] + value;

return true;

}

from is the transfering balance account address

msg.sender is the current account address

First subtract the value to balance(from) address.

Subtract the value to balance(current) address. This address transfer the value to receiver.

Add the value to balance(receiver) address.

Approve():

It approves the who access the transaction and how many tokens. Give approvel to another address

function approve(address spender, uint256 token) public returns(bool success){

allowed[msg.sender][spender] = token;

return true;

}

spender is who access the the token from address and give access to the token count.

Add a comment

Related posts:

What Was It Doing There? Quick Anecdotes Of Games We Found In The Weirdest Locations

Imagine never being able to play the one game you enjoyed so much as a kid. The thought of a beloved game being lost would scare most gamers: Mario Kart gone without a trace, Sonic and Knuckles…