I am new to ethereum block-chain. I create a ERC20 base smart contract. I set decimals values 18. When I call transfer function and pass the address and value parameters. So it's convert no.of token value into decimals. I want to it integer number.
I follow answer:- Correct way to transfer ERC-20 tokens and keeping decimals in count?
But one thing I can not understand how to intelize temporary variable and pass it on transfer function. I can do this way:-
Solidity code:-
contract StandardToken is ERC20, BasicToken {
using SafeMath for uint256;
// Name
string public name = "Autobay";
// Symbol
string public symbol = 'ABX';
//standard
string public standard = 'ABX 0.1';
//token price
uint256 public tokenPrice = 100000; //in wei
uint256 public amount;
//decimals
uint256 public constant decimals = 18;
uint256 public totalSupply;
constructor(uint256 _intialSupply) {
balances[msg.sender] = _intialSupply;
totalSupply = _intialSupply;
}
event Transfer(address indexed _form,address indexed _to,uint256 amount);
event Approval(address indexed _owner,address indexed _spender,uint256 _value);
mapping (address => mapping (address => uint256)) internal allowed;
function transfer(address _to, uint256 _value) public returns (bool) {
amount = _value * 10**decimals;
require(_to != address(0));
require(amount <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(amount);
balances[_to] = balances[_to].add(amount);
emit Transfer(msg.sender, _to, amount);
return true;
}
}
When I call transfer function nothing change. So where I do mistake. Please anyone resolve my query.
It might be a silly question but here i want to understand this concept more deeply.
Please help to clear my above query.
Thanks