以太坊代币的开发

本文介绍了如何使用Remix和MetaMask来开发以太坊代币。通过提供一个基础的TokenERC20合约代码,阐述了代币的创建、转移、授权和销毁等关键操作。合约中包含了必要的事件触发和安全检查,适用于初学者理解以太坊智能合约的开发流程。
摘要由CSDN通过智能技术生成

本文用的是Remix+MetaMask开发代币。

在线编辑器网站:https://remix.ethereum.org/#optimize=false&version=soljson-v0.5.1+commit.c8a2cb62.js

在谷歌上安装MetaMask插件。

基础代币的合约:

pragma solidity >=0.4.22 <0.6.0;

interface tokenRecipient { 
    function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; 
}

contract TokenERC20 {
    string public name;// Public variables of the token
    string public symbol;
    uint8 public decimals = 18;
    uint256 public totalSupply;    // 18 decimals is the strongly suggested default, avoid changing it
    mapping (address => uint256) public balanceOf;  // This creates an array with all balances
    mapping (address => mapping (address => uint256)) public allowance;
    event Transfer(address indexed from, address indexed to, uint256 value);  // This generates a public event on the blockchain that will notify clients
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);// This generates a public event on the blockchain that will notify clients
    event Burn(address indexed from, uint256 value);    // This notifies clients about the amount burnt

    /**
     * Constructor function
     *
     * Init

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值