TOKEN-BEP20 – 代币-BEP20区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,TOKEN-BEP20 – 代币-BEP20区块链毕设代写 是一篇很好的国外资料

TOKEN-BEP20

pragma solidity 0.5.16; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. / function totalSupply() external view returns (uint256); /* * @dev Returns the token decimals. / function decimals() external view returns (uint8); /* * @dev Returns the token symbol. / function symbol() external view returns (string memory); /* * @dev Returns the token name. / function name() external view returns (string memory); /* * @dev Returns the bep token owner. / function getOwner() external view returns (address); /* * @dev Returns the amount of tokens owned by account. / function balanceOf(address account) external view returns (uint256); /* * @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 recipient, uint256 amount) external returns (bool); /* * @dev Returns the remaining number of tokens that spender will be * allowed to spend on behalf of owner through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. / function allowance(address _owner, address spender) external view returns (uint256); /* * @dev Sets amount as the allowance of spender over the caller’s tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender’s allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. / function approve(address spender, uint256 amount) external returns (bool); /* * @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 sender, address recipient, uint256 amount) external returns (bool); /* * @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); } / * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. / contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode – see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /* * @dev Wrappers over Solidity’s arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * SafeMath restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it’s recommended to use it always. / library SafeMath { /* * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity’s + operator. * * Requirements: * – Addition cannot overflow. / function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, “SafeMath: addition overflow”); return c; } /* * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity’s - operator. * * Requirements: * – Subtraction cannot overflow. / function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, “SafeMath: subtraction overflow”); } /* * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity’s - operator. * * Requirements: * – Subtraction cannot overflow. / function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a – b; return c; } /* * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity’s * operator. * * Requirements: * – Multiplication cannot overflow. / function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring ‘a’ not being zero, but the // benefit is lost if ‘b’ is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, “SafeMath: multiplication overflow”); return c; } /* * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity’s / operator. Note: this function uses a * revert opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * – The divisor cannot be zero. / function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, “SafeMath: division by zero”); } /* * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity’s / operator. Note: this function uses a * revert opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * – The divisor cannot be zero. / function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn’t hold return c; } /* * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity’s % operator. This function uses a revert * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * – The divisor cannot be zero. / function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, “SafeMath: modulo by zero”); } /* * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity’s % operator. This function uses a revert * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * – The divisor cannot be zero. / function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /* * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * onlyOwner, which can be applied to your functions to restrict their use to * the owner. / contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /* * @dev Initializes the contract setting the deployer as the initial owner. / constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /* * @dev Returns the address of the current owner. / function owner() public view returns (address) { return _owner; } /* * @dev Throws if called by any account other than the owner. / modifier onlyOwner() { require(_owner == _msgSender(), “Ownable: caller is not the owner”); _; } /* * @dev Leaves the contract without owner. It will not be possible to call * onlyOwner functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. / function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /* * @dev Transfers ownership of the contract to a new account (newOwner). * Can only be called by the current owner. / function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /* * @dev Transfers ownership of the contract to a new account (newOwner). / function _transferOwnership(address newOwner) internal { require(newOwner != address(0), “Ownable: new owner is the zero address”); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract BEP20Token is Context, IBEP20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = “Cardano Lite”; _symbol = “ADALITE”; _decimals = 9; _totalSupply = 100000010*18 ; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the bep token owner. / function getOwner() external view returns (address) { return owner(); } /* * @dev Returns the token decimals. / function decimals() external view returns (uint8) { return _decimals; } /* * @dev Returns the token symbol. / function symbol() external view returns (string memory) { return _symbol; } /* * @dev Returns the token name. / function name() external view returns (string memory) { return _name; } /* * @dev See {BEP20-totalSupply}. / function totalSupply() external view returns (uint256) { return _totalSupply; } /* * @dev See {BEP20-balanceOf}. / function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /* * @dev See {BEP20-transfer}. * * Requirements: * * – recipient cannot be the zero address. * – the caller must have a balance of at least amount. / function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /* * @dev See {BEP20-allowance}. / function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /* * @dev See {BEP20-approve}. * * Requirements: * * – spender cannot be the zero address. / function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /* * @dev See {BEP20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {BEP20}; * * Requirements: * – sender and recipient cannot be the zero address. * – sender must have a balance of at least amount. * – the caller must have allowance for sender‘s tokens of at least * amount. / function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, “BEP20: transfer amount exceeds allowance”)); return true; } /* * @dev Atomically increases the allowance granted to spender by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * – spender cannot be the zero address. / function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /* * @dev Atomically decreases the allowance granted to spender by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * – spender cannot be the zero address. * – spender must have allowance for the caller of at least * subtractedValue. / function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, “BEP20: decreased allowance below zero”)); return true; } /* * @dev Creates amount tokens and assigns them to msg.sender, increasing * the total supply. * * Requirements * * – msg.sender must be the token owner / function mint(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /* * @dev Moves tokens amount from sender to recipient. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * – sender cannot be the zero address. * – recipient cannot be the zero address. * – sender must have a balance of at least amount. / function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), “BEP20: transfer from the zero address”); require(recipient != address(0), “BEP20: transfer to the zero address”); _balances[sender] = _balances[sender].sub(amount, “BEP20: transfer amount exceeds balance”); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /* @dev Creates amount tokens and assigns them to account, increasing * the total supply. * * Emits a {Transfer} event with from set to the zero address. * * Requirements * * – to cannot be the zero address. / function _mint(address account, uint256 amount) internal { require(account != address(0), “BEP20: mint to the zero address”); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /* * @dev Destroys amount tokens from account, reducing the * total supply. * * Emits a {Transfer} event with to set to the zero address. * * Requirements * * – account cannot be the zero address. * – account must have at least amount tokens. / function _burn(address account, uint256 amount) internal { require(account != address(0), “BEP20: burn from the zero address”); _balances[account] = _balances[account].sub(amount, “BEP20: burn amount exceeds balance”); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /* * @dev Sets amount as the allowance of spender over the owners tokens. * * This is internal function is equivalent to approve, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * – owner cannot be the zero address. * – spender cannot be the zero address. / function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), “BEP20: approve from the zero address”); require(spender != address(0), “BEP20: approve to the zero address”); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /* * @dev Destroys amount tokens from account.amount is then deducted * from the caller’s allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, “BEP20: burn amount exceeds allowance”)); } }

Delete lite.png


TOKEN-BEP20

pragma固结度0.5.16;接口IBEP20{/***@dev返回存在的令牌数量。/函数totalSupply()外部视图返回(uint256);/**@dev返回标记小数。/函数decimals()外部视图返回(uint8);/**@dev返回令牌符号。/函数symbol()外部视图返回(字符串内存);/**@dev返回令牌名称。/function name()外部视图返回(字符串内存);/**@dev返回bep令牌所有者。/函数getOwner()外部视图返回(地址);/**@dev返回帐户拥有的令牌数量。/函数balanceOf(address account)外部视图返回(uint256);/**@dev将amount令牌从呼叫者的帐户移动到接收者。**返回一个布尔值,指示操作是否成功。**发出{Transfer}事件。/函数传输(地址接收者,uint256金额)外部返回(bool);/**@dev返回允许spender*通过{transferFrom}代表所有者花费的剩余令牌数。默认为*零。**调用{approve}或{transferFrom}时,此值会更改。/函数余量(地址所有者,地址使用者)外部视图返回(uint256);/**@dev将amount设置为对调用方令牌的开销限额。**返回一个布尔值,指示操作是否成功。**重要提示:请注意,使用此方法更改备抵会带来风险,即有人可能通过不幸的交易顺序同时使用旧备抵和新备抵。缓解这种竞争状况的一个可能的解决方案是,首先将消费者的津贴减少到0,然后再设置*所需的值:*https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729**发出{Approval}事件。/功能批准(地址spender,uint256 amount)外部退货(bool);/**@dev使用*allowment机制将amount令牌从发送方移动到接收方。然后从来电者的*津贴中扣除金额。**返回一个布尔值,指示操作是否成功。**发出{Transfer}事件。/函数transferFrom(地址发送方,地址接收方,uint256 amount)外部返回(bool);/**@当值令牌从一个帐户(从)移动到*另一个帐户(到)时发出的设备请注意,该值可能为零事件传输(地址索引自,地址索引至,uint256值);/**@dev在通过调用{approve}设置所有者的消费限额时发出。值是新的容差。/事件批准(地址索引所有者、地址索引使用者、uint256值);}/*@dev提供有关当前执行上下文的信息,包括事务的*发送方及其数据。虽然它们通常通过msg.sender和msg.data*提供,但不应以这种直接*方式访问它们,因为在处理GSN元事务时,发送和*支付执行的帐户可能不是实际的发送者(就应用程序*而言)。**此合同仅适用于中间的、类库合同。/契约上下文{//为空的内部构造函数,以防止人们错误地部署//此契约的实例,该实例应通过继承使用。构造函数()内部{}函数{u msgSender()内部视图返回(应付地址){return msg.sender;}函数_msgData()内部视图返回(字节内存){this;//静默状态可变警告而不生成字节码-请参阅https://github.com/ethereum/solidity/issues/2691 返回msg.data;}}/**@dev包装Solidity的算术运算,添加溢出*检查。**实度算术运算在溢出时换行。这很容易导致*错误,因为程序员通常认为溢出会引发*错误,这是高级编程语言的标准行为。*SafeMath通过在*操作溢出时还原事务来恢复这种直觉。**使用此库而不是未检查的操作可以消除整个*类错误,因此建议始终使用它。/库SafeMath{/**@dev返回两个无符号整数的加法,在*溢出时还原。**对应于Solidity的+运算符。**要求:*-添加不能溢出。/函数add(uint256 a,uint256 b)内部纯返回(uint256){uint256 c=a+b;要求(c&gt;=a、 “SafeMath:加法溢出”);返回c;}/**@dev返回两个无符号整数的减法,在*溢出时恢复(当结果为负时)。**对应于Solidity的-运算符。**要求:*-减法不能溢出。/函数sub(uint256 a,uint256 b)内部纯返回(uint256){返回sub(a,b,“SafeMath:减法溢出”);}/**@dev返回两个无符号整数的减法,并在*溢出时使用自定义消息还原(当结果为负时)。**对应于Solidity的-运算符。**要求:*-减法不能溢出。/function sub(uint256 a,uint256 b,string memory errorMessage)内部纯返回(uint256){require(b&lt;=a、 错误消息);uint256 c=a-b;返回c;}/**@dev返回两个无符号整数的乘法,在*溢出时还原。**对应于Solidity的*运算符。**要求:*-乘法不能溢出。/函数mul(uint256 a,uint256 b)内部纯返回(uint256){//Gas优化:这比要求“a”不为零要便宜,但如果同时测试“b”,则//请参见:https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 如果(a==0){返回0;}uint256 c=a*b;require(c/a==b,“SafeMath:乘法溢出”);返回c;}/**@dev返回两个无符号整数的整数除法。还原为*除零。结果四舍五入为零。**对应于Solidity公司/运营商。注:此函数使用*还原操作码(使剩余气体保持不变),而Solidity*使用无效操作码还原(消耗所有剩余气体)。**要求:*-除数不能为零。/函数div(uint256 a,uint256 b)内部纯返回(uint256){返回div(a,b,“SafeMath:除零”);}/**@dev返回两个无符号整数的整数除法。用*除零上的自定义消息还原。结果四舍五入为零。**对应于Solidity公司/运营商。注:此函数使用*还原操作码(使剩余气体保持不变),而Solidity*使用无效操作码还原(消耗所有剩余气体)。**要求:*-除数不能为零。/函数div(uint256 a,uint256 b,string memory errorMessage)内部纯返回(uint256){//Solidity仅在除以0时自动断言require(b&gt;0,错误消息);uint256 c=a/b;//断言(a==b*c+a%b);//在任何情况下,这都包含return c;}/**@dev返回除两个无符号整数的余数(无符号整数(模),*除以零时还原。**对应于Solidity的%运算符。此函数使用revert*操作码(使剩余气体保持不变),而SOLIDATY使用*invalid操作码进行还原(消耗所有剩余气体)。**要求:*-除数不能为零。/函数mod(uint256 a,uint256 b)内部纯返回(uint256){返回mod(a,b,“SafeMath:modulo by zero”);}/**@dev返回除两个无符号整数的余数(无符号整数(模),*除以零时用自定义消息还原。**对应于Solidity的%运算符。此函数使用revert*操作码(使剩余气体保持不变),而SOLIDATY使用*invalid操作码进行还原(消耗所有剩余气体)。**要求:*-除数不能为零。/函数mod(uint256 a,uint256 b,string memory errorMessage)内部纯返回(uint256){require(b!=0,错误消息);返回a%b;}}/**@dev Contract模块,提供基本的访问控制机制,其中*有一个帐户(所有者),可以被授予对*特定功能的独占访问权。**默认情况下,所有者帐户将是部署合同的帐户。这个*稍后可以用{transferOwnership}.**更改此模块通过继承使用。它将使修饰符*onlyOwner可用,它可以应用于您的函数,以将它们的使用限制为*所有者。/contract Ownable是Context{address private}owner;事件所有权已转移(地址索引为previousOwner,地址索引为newOwner);/**@dev初始化契约,将部署者设置为初始所有者。/构造函数()内部{address msgSender=u msgSender()_所有者=msgSender;发出OwnershipTransferred(地址(0),msgSender);}/**@dev返回当前所有者的地址。/函数owner()public view返回(address){returnu owner;}/**@如果由所有者以外的任何帐户调用,dev将抛出。/修饰符onlyOwner(){require(u owner==u msgSender(),“Ownable:调用者不是所有者”);ux;}/**@德夫没有主人就离开了合同。将无法再调用*onlyOwner函数。只能由当前所有者调用。**注:放弃所有权将使合同失去所有者,*从而删除任何仅对所有者可用的功能。/函数renounceOwnership()public onlyOwner{emit OwnershipTransferre

Delete lite.png

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/22773.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » TOKEN-BEP20 – 代币-BEP20区块链毕设代写

提供最优质的资源集合

立即查看 了解详情