聚焦资讯
服务于区块链创业者

币安BSC智能链发币教程——remix+metamask实现币安BSC链上发币【pdf+视频BSC发币教程下载】

chatGPT账号

一、准备:
1、使用在线的remix IDE或者搭建本地remixIDE都可以,优先选择在线的ide,中小项目足够了,但是在线remix的编译器版本加载有些慢,必要时需要KXSW。另外,在线的IDE现在偶尔出现加载速度过慢的情况,部分IDE不可用。
2、metamask钱包配置连接BSC主网,钱包中要有BNB,发币时消耗的BNB,这点区别于波场发币,波场消耗的是带宽和能量
metamask要充值足够的BNB否则合约发行失败,还会消耗掉你的BNB,发行一个标准代币的成本大约需要消耗0.0003BNB,折合1$
3、合约接口要实现ERC20标准
4、部署合约时,要选择inject web3,新版本的remix编译器为web3 provider-metamask,连接上metamask钱包的用户来部署合约。
【附注20221212】
remix作为主流的合约编译器IDE,可以支持所有ERC20标准的协议合约编译及部署。配合web3客户端metamask可以实现将合约部署到所有ERC20标准的区块链上。合约部署到哪个链上取决于metamask当前所链接的RPC区块链节点。大部分合约代码可以在所有ERC20标准的公链上通用。但是针对特点dex或者address的特殊变量需要针对不同的dex进行调整。各大公链的区别主要有如下几点:
a. 不同公链对应的dex是不同的,相应的dex的routerv2地址也是不同的,在部署合约时需要做相关的调整
b. 不同公链上调用weth的方式是不同的,okc和bsc调用方式有显著区别,需要做相关调整
c. bsc链上对bnb不能做强制IERC20的类型转换,transfer时会报错
d. bsc链有自己特定的地址,比如黑洞地址为0x0000000000000000000000Dead,该地址只在bsc链上有效
 
二、注意事项
1、发币完成后要记录交易的hash id,通过bscscan浏览器查询合约是否部署成功,并且获得发布的token的合约地址
2、bsc上发布合约后,暂时没有渠道可以上传通证logo,这点不如波场,在波场上可以自由上传更新logo。在tp钱包上传logo需要赞助5w tpt折合500U
3、发币时建议首先在bsc的测试网上发布下合约,在钱包中转账,测试下是否满足合约中设定的模式。没有问题后再在bsc主网上发币。合约中涉及线上博饼pancakeswap交易的模式就需要直接在BSC的主网部署合约了。
三、具体发币步骤
1、打开remix在线IDE或者本地IDE环境
官网remix网址:https://remix.ethereum.org/,本示例使用的是本地remixIDE环境
bsc21091605
注:本地remix环境频繁出现调用metamask异常问题,主要原因是本地连接BSC主网节点异常导致的。
2、创建合约文件
如果有多个文件,项目比较复杂的话,可以在根目录下创建文件夹,每发行一个代币保存到一个文件夹中,这样便于管理。
本示例以标准代币发行为例演示发币过程
在BSCS文件夹下创建五个sol文件:分别为IERC20.sol,SafeMath.sol,ERC20Detailed..sol,ERC20.sol,Tokenl.sol
对应的文件代码如下:
IERC20.sol文件:
pragma solidity ^0.5.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @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);
}

SafeMath.sol文件:

pragma solidity ^0.5.0;

/**
 * @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;
    }

ERC20Detailed.sol 文件:

pragma solidity ^0.5.0;

import "./IERC20.sol";

/**
 * @dev Optional functions from the ERC20 standard.
 */
contract ERC20Detailed is IERC20 {
    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
     * these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name, string memory symbol, uint8 decimals) public {
        _name = name;
        _symbol = symbol;
        _decimals = decimals;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view returns (string memory) {
        return _symbol;
    }

ERC20.sol 文件:

pragma solidity ^0.5.0;

import "./IERC20.sol";
import "./SafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20Mintable}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

Token.sol 文件:

// 0.5.1-c8a2
// Enable optimization
pragma solidity ^0.5.0;

import "./ERC20.sol";
import "./ERC20Detailed.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract Token is ERC20, ERC20Detailed {

    /**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */
    constructor () public ERC20Detailed("Water Drop", "DROP", 18) {
        _mint(msg.sender, 10000 * (10 ** uint256(decimals())));
    }
}
修改token.sol文件的合约全称,简称,发行数量。本示例发行代币全称为Water Drop,简称为 DROP,发行总量为 10000
以上文件创建完成后保存会自动编译。
编译器版本选择0.5.15
bsc21091606
注:新版本的合约已经全部迁移到支持0.6.12版本的编译器上 了,主流的合约已经开始迁移到0.8.14版本了。0.5.15版本的合约已经过于陈旧了。
3、部署合约
所有合约文件编译通过后,就可以部署合约了。
remix IDE支持以太坊,BSC,HECO链上部署合约,代码在所有链上完全一致,不需要任何针对平台的调整。
决定合约部署到哪个公链上,取决于metamask钱包当前连接到哪个公链上。
比如本示例想部署到BSC公链上,此时metamask就必须连接BSC主网:
然后在remix IDE上部署已经编译成功的合约:bsc21091608
4、合约部署完成后,在BSC区块链浏览器上查询hash id,确认合约是否部署成功。
点击deploy执行合约部署后,在remix控制台输出如下:
bsc21091609
其中最重要的信息是 transaction hash值,记录该值,到区块链浏览器上查询该值。
bsc21091610
区块链浏览器显示该transcation hash对应的交易执行成功,合约成功部署,对应的合约地址为以上截图信息。
5、metamask钱包添加发行的代币
bsc21091611
metamask钱包发币账户成功添加刚刚发行的代币,至此BSC主网发币完成。
区别于波场发币,波场发币完成后需要在tronscan上录入通证,同时上传logo。但是bsc链上不允许自定义logo,logo都是发币完成后自动生成的。
至此,remix+metamask实现币安BSC链上发币完成。

pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载:

币安智能链BSC发币(合约部署、开源、锁仓、LP、参数配置、开发、故障处理、工具使用)教程下载:

多模式(燃烧、回流指定营销地址、分红本币及任意币种,邀请推广八代收益,LP加池分红、交易分红、复利分红、NFT分红、自动筑池、动态手续费、定时开盘、回购)组合合约源代码下载:

pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载地址:

此内容仅供注册用户可见,请登录!

添加VX或者telegram获取全程线上免费指导

 

免责声明

发文时比特币价格:$16249

免责声明:

本文不代表行至网立场,且不构成投资建议,请谨慎对待。用户由此造成的损失由用户自行承担,与行至网没有任何关系;

行至网不对网站所发布内容的准确性,真实性等任何方面做任何形式的承诺和保障;

网站内所有涉及到的区块链(衍生)项目,行至网对项目的真实性,准确性等任何方面均不做任何形式的承诺和保障;

网站内所有涉及到的区块链(衍生)项目,行至网不对其构成任何投资建议,用户由此造成的损失由用户自行承担,与行至网没有任何关系;

行至区块链研究院声明:行至区块链研究院内容由行至网发布,部分来源于互联网和行业分析师投稿收录,内容为行至区块链研究院加盟专职分析师独立观点,不代表行至网立场。

chatGPT账号
赞(0) 打赏
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权,未经允许不得转载。
文章名称:《币安BSC智能链发币教程——remix+metamask实现币安BSC链上发币【pdf+视频BSC发币教程下载】》
文章链接:https://www.xingzhi.io/definance/10931.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

服务于区块链创业者

业务范围商务合作

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的区块链世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录后才能复制或下载网站内容