Practical No 7BLC
Practical No 7BLC
What is ERC20?
An ERC20 token is a standard used for creating and issuing smart contracts on the
Ethereum blockchain. Smart contracts can then be used to create smart property or
tokenized assets that people can invest in. ERC stands for Ethereum request for
comment,and the ERC20 standard was implemented in 2015
ERC20 is a technical standard used for smart contracts on the Ethereum blockchain to
implement fungible tokens. "ERC" stands for Ethereum Request for Comment, and "20"
is the proposal identifier.
ERC20 defines a common set of rules for how tokens behave, allowing compatibility with
wallets, exchanges, and dApps (decentralized applications).
They are widely used for crowdfunding (ICOs), DeFi, NFT marketplaces (for payment
tokens), and more.
The ERC20 standard defines six mandatory functions and three optional metadata
functions:
Function Description
totalSupply() Returns the total number of tokens in existence.
balanceOf(address) Returns the token balance of a specific address.
transfer(address, uint256) Transfers tokens from the sender to another
address.
approve(address, uint256) Allows another address to spend a certain amount
of tokens on the sender’s behalf.
transferFrom(address, address, Transfers tokens on behalf of someone else (used
uint256)
with approve).
allowance(address, address) Returns how much an address is allowed to spend
on behalf of another.
Code:
import java.util.HashMap;
import java.util.Map;
this.name = name;
this.symbol = symbol;
this.decimals = decimals;
System.out.println("Insufficient balance");
return;
System.out.println("Transfer successful: " + amount + " from " + from + " to " +
to);
return name;
return symbol;
}
public int getDecimals() {
return decimals;
token.balances.put("Alice", 1000);
token.balances.put("Bob", 500);
token.balances.put("Charlie", 200);
System.out.println("Final Balances:");
}
Output: