币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

  • A+
所属分类:币安BSC
摘要

代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程。
代币私募完成后,每个地址私募相同数量的代币,但是代币是线性释放模式,即每天定时定量将私募的代币下发到私募钱包地址,固定周期内释放完成;
锁仓指定数量的代币,每天定时线性释放代币到原来的锁定地址;
质押挖矿模式,用户质押指定数量的WETH到合约地址中,合约地址每天线下释放挖矿收益币种到质押来源地址。


chatGPT账号
一、准备
本合约主要实现代币的定量和百分比模式的下发。用户根据需要选择定量或者百分比将合约地址中的代币下发到指定的钱包地址,每天固定时间调用合约,将合约地址中的代币下发给指定的用户。该合约适用于如下业务需求场景:
场景一:代币私募完成后,每个地址私募相同数量的代币,但是代币是线性释放模式,即每天定时定量将私募的代币下发到私募钱包地址,固定周期内释放完成。
场景二:锁仓指定数量的代币,每天定时线性释放代币到原来的锁定地址。
场景三:质押挖矿模式,用户质押指定数量的WETH到合约地址中,合约地址每天线下释放挖矿收益币种到质押来源地址。
该合约主要包括如下功能:
1、代币可以每天定时下发固定数量的代币到指定的下发地址中。
2、代币可以每天定时下发当前合约地址代币余额固定百分比数量的代币到指定的下发地址中。
3、下发地址预先配置到合约中,在后期可以排除下发地址。
4、合约具备合约所有权,只有合约所有权账号才可以配置合约的动态参数。
5、支持赎回BNB,和所有ERC20标准的代币
6、支持设置批量下发的gas费用上限,根据下发地址数量,动态调整gas费用上限。
7、合约中限定了批量下发的代币合约地址,必须是指定的代币才能实现批量下发,转入其他代币无法实现批量下发功能。
8、两次下发的冷却时间是200个块高度,避免误操作导致的短时间内重复下发。
二、合约部署
1、合约主要有以下几个sol文件组成
IERC20.sol
SafeMath.sol
IERC20Metadata.sol
Context.sol
Ownable.sol
Address.sol
Tools.sol

2、配置编译器相关的参数

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

3、按照以下顺序编译合约文件

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

4、部署合约

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

选择metamask钱包作为web3客户端,部署合约
要部署的目标合约名称为Tools
fundaddress: 赎回BNB时,目标接收地址
issuedToken:批量下发的代币合约地址
rationcounts:定量下发的次数
5、合约部署完成后,根据transaction hash确定合约地址,确认合约部署详情
 币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】
6、核心部分功能源代码如下:
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

通过以上address类地址工具包处理相关地址定量或者百分比下发及线性释放代币的核心功

三、完整版本的合约源码

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

至此,完成代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程所有操作环节。

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

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

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

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

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】

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

此处为隐藏的内容!
登录后才能查看!

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

币安智能链BSC发币教程——代币锁定后定量或者百分比定期下发线性释放到指定钱包地址合约部署操作流程【pdf+视频币安链BSC发币教程下载】
免责声明

免责声明:

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

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

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

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

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

本文是全系列中第150 / 237篇:通证发行

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的电报
  • 这是我的电报扫一扫
  • weinxin
chatGPT账号

发表评论

您必须登录才能发表评论!