// SPDX-License-Identifier: UNLISCENSED
pragma solidity 0.8.4;
contract ClassicCornerstoneZenithal {
string public name = "Classic Cornerstone Zenithal";
string public symbol = "ZENITHAL";
uint256 public totalSupply = 21000000000000000000000000; // 21 million tokens
uint8 public decimals = 18;
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed _from, address indexed _to, uint256 _value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor() {
balanceOf[msg.sender] = totalSupply;
}
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address _to, uint256 _value)
public
returns (bool success)
{
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits an {Approval} event.
*/
function approve(address _spender, uint256 _value)
public
returns (bool success)
{
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address _from,
address _to,
uint256 _value
) public returns (bool success) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
}
Thanks for your reply Sir, I have compiled the contract on remix ide but its giving some Gas & Economy cost and Miscellaneous warning signs. Should I just go ahead and deploy?. Thanks for your Help
Is this suppose to be an ERC20?
It's Binance Smart chain bep20
Hey Guys, i.just deployed the contract but I am having difficulties verifying it on bscscan. I keep getting the "error unable to generate bytecode and ABI. Any help will be much appreciated
Hi, I think before you deploy contracts, you can write some test cases to test your contracts, and if you want to deploy an ERC20 token quickly, I think you can have a try with the tool: OpenZeppelin Contracts Wizard
As for the error when you tried to verify contracts, I think you can have a look at this tutorial:
Thanks guys, I have verified my contract. Cheers
Guys, is it possible to renounce the ownership of this contract?
Your contract does not have a role like owner
, and all functions are public to everyone and do not have permissions
Thanks for your reply. Pls what does 'Public to everyone' mean?. Hope my contract won't be compromised?
Not compromised, but there is no owner. According to the contract constructor, the deployer of the contracts gets all the initial supply. Then the deployer can transfer tokens to any wallet. Apart from that there is no need for an owner in this contract.
In any case, and in line with previous comments, I recommend you to use the ERC20 contract from OpenZeppelin. You can use the contract generator as mentioned above by @Skyge. It will save you a lot of trouble!
Thanks for your reply, I think the contract is perfect for the purpose I need it for. I don't have to bother about ownership being renounced to get the trust of the token users. Just a simple token that can be transferred and received without the worries of anyone locking the token users out.
One more question guys, do I really need to audit the contract?
It all depends on the amount of trust you want to gain from your token holders. Being a custom made contract it could contain bugs that could be exploited. For example it comes to mind that your contract suffers from the approve front-running issue (https://www.adrianhetman.com/unboxing-erc20-approve-issues/). Nothing very serious, but just so you understand my point. On the other hand an audit is usually quite expensive, and in your case I don't think I would advise it, unless you are planning for a marketing stunt in which you advertise that your project has been audited. Again, you could do something similar if you use a battle-tested code like Open Zeppelin (or other), so you could have peace of mind about the quality of the code and also advertise it to your holders.
Thanks for your reply, I will look for a cheap or free smart contract audit services online apart from techrate. Any suggestions?
Hey guys, does anyone have an idea on how to lock my tokens for vesting periods?. I will like to do it myself. Thanks