HashLand
  • welcome
    • Get to know us
    • Related Links
  • electricity
    • About HashLand Electricity
    • Daily Income
    • Contract
    • FAQ
  • GameFi
    • Hash Warfare
      • Hero
      • Game items
      • Game currency
      • Introduction of game props
      • Introduction of profile photo
      • Rank
      • Store
      • Team formation
      • Album
      • Mailbox
      • Friend system
      • Carnival
      • Daily task
      • Battle
      • PVP
      • Challenge
        • Space Exploration
        • Fissure of the Earth core
        • Astrolabe travel
        • Galaxy Ground
      • Game Mechanics
        • PVE
        • PVP
  • white paper
    • Abstract
    • HashLand Introduction
    • HashLand Purpose
    • HashLand NFT
      • Synthetic NFT Forging
      • Synthetic NFT Expandability
    • HashLand Application
      • S-NFT Card Levels And Mining Hash Rate
      • Purchase Contract
      • Blind Box Purchase Contract
      • S-NFT Cards Upgrade Contract
    • HashLand GameFi
    • Platform Token
      • HC Tokenomics
      • HC Token Purpose
    • Others
      • Roadmap
      • Risk Disclosure
      • Legal Information and Communications
  • DAO
    • About DAO
    • DAO Treasury
    • DAO Proposal
Powered by GitBook
On this page
  1. white paper
  2. HashLand Application

Purchase Contract

Level 1 S-NFT can be purchased at our official website, authorized third party sellers, or the Market.

function buy(uint256[] calldata _hnIds) external nonReentrant {
        address[] memory _sellers = new address[](_hnIds.length);
        uint256[] memory prices = new uint256[](_hnIds.length);
        bool[] memory isInPools = new bool[](_hnIds.length);

     for (uint256 i = 0; i < _hnIds.length; i++) {
        require(hnIds.contains(_hnIds[i]), "This HN does not exist");
        prices[i] = hnPrice[_hnIds[i]];
        uint256 feeAmount = (prices[i] * feeRatio) / 1e4;
        uint256 sellAmount = prices[i] - feeAmount;

        _sellers[i] = hnSeller[_hnIds[i]];
        isInPools[i] = hnIsInPool[_hnIds[i]];

        hnIds.remove(_hnIds[i]);
        sellerHnIds[_sellers[i]].remove(_hnIds[i]);

        busd.transferFrom(msg.sender, _sellers[i], sellAmount);
        busd.transferFrom(msg.sender, receivingAddress, feeAmount);
        if (isInPools[i]) {
            hnPool.hnMarketWithdraw(msg.sender, _sellers[i], _hnIds[i]);
        } else {
            hn.safeTransferFrom(address(this), msg.sender, _hnIds[i]);
        }

        sellerTotalSellAmount[_sellers[i]] += sellAmount;
        sellerTotalSellCount[_sellers[i]]++;

        buyerTotalBuyAmount[msg.sender] += sellAmount;
        buyerTotalBuyCount[msg.sender]++;

        totalSellAmount += sellAmount;
        totalFeeAmount += feeAmount;
        totalSellCount++;
    }
    buyers.add(msg.sender);

    emit Buy(msg.sender, _sellers, _hnIds, prices, isInPools);
}
PreviousS-NFT Card Levels And Mining Hash RateNextBlind Box Purchase Contract

Last updated 3 years ago