FDF互助遊戲智慧合約開發(馬蹄鏈開發)

lovei130908發表於2023-03-10

區塊鏈是一種塊鏈式資料結構,以時間先後為基準,將儲存資料的區塊以順序相連的形式相結合,同時以密碼學方式確保資料的不可篡改和不可偽造,是一種安全性極高的分散式賬本。廣義來講,區塊鏈利用塊鏈式資料結構來對資料進行驗證與儲存、利用分散式節點共識演演算法對資料進行更新、利用密碼學方式確保資料的傳輸與訪問安全、利用自動化指令碼編寫的智慧合約來對資料進行程式設計和操作,是一種全新的分散式架構基礎與計算方式 系統開發 180-383I-97Z4

  // SPDX-License-Identifier: UNLICENSED

 

pragma solidity 0.8.16;

 

import "./MasterChefHelper.sol";

 

interface WETH9 is ERC20Like {

     function deposit() external payable;

}

 

contract Setup {

    

     WETH9 public constant weth = WETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

     MasterChefHelper public immutable mcHelper;

 

     constructor() payable {

         mcHelper = new MasterChefHelper();

         weth.deposit{value: 10 ether}();

         weth.transfer(address(mcHelper), 10 ether); // whoops

     }

 

     function isSolved() external view returns (bool) {

         return weth.balanceOf(address(mcHelper)) == 0;

     }

 

}

uint public constant MINIMUM_LIQUIDITY=10**3;

   //獲取transfer方法的bytecode前四個位元組

   bytes4 private constant SELECTOR=bytes4(keccak256(bytes('transfer(address,uint256)')));

   address public factory;

   address public token0;

   address public token1;

   uint112 private reserve0;//uses single storage slot,accessible via getReserves==使用單個儲存槽,可透過getReserves訪問

   uint112 private reserve1;//uses single storage slot,accessible via getReserves

   uint32 private blockTimestampLast;//uses single storage slot,accessible via getReserves

   uint public price0CumulativeLast;//最後價格累計的0價格?

   uint public price1CumulativeLast;
   //緊接最近一次流動性事件之後

   uint public kLast;//reserve0*reserve1,as of immediately after the most recent liquidity event

   uint private unlocked=1;

   //防止遞迴迭代出現問題,所以要上鎖

   //一個鎖,使用該modifier的函式在unlocked==1時才可以進入,

   //第一個呼叫者進入後,會將unlocked置為0,此使第二個呼叫者無法再進入

   //執行完_部分的程式碼後,才會再將unlocked置1,重新將鎖開啟

   modifier lock(){

   require(unlocked==1,'UniswapV2:LOCKED');

   unlocked=0;

   _;

   unlocked=1;

   }

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70021343/viewspace-2939023/,如需轉載,請註明出處,否則將追究法律責任。

相關文章