NFT(數(shù)字藏品)開(kāi)發(fā)方案丨NFT(數(shù)字藏品)系統(tǒng)開(kāi)發(fā)(開(kāi)發(fā)項(xiàng)目及功能)
數(shù)字藏品是指使用是指使用區(qū)域鏈技術(shù),對(duì)應(yīng)特定的作品、藝術(shù)品生成的唯一數(shù)字憑證,在保護(hù)其數(shù)字版權(quán)的基礎(chǔ)上,實(shí)現(xiàn)真實(shí)可信的數(shù)字化發(fā)行,購(gòu)買(mǎi)收藏和使用。
在createPool函數(shù)中首先會(huì)檢查tokenA與tokenB是否是同一Token,之后將TokenA與TokenB根據(jù)地址進(jìn)行升序排列,之后檢查token0地址是否為空地址,之后根據(jù)費(fèi)率檢索TickSpace并檢查T(mén)ickSpace是否為0(構(gòu)造函數(shù)會(huì)進(jìn)行初始化一次),之后檢查當(dāng)前新建的池子是否已經(jīng)存在,之后通過(guò)deploy創(chuàng)建池子,然后新增池子記錄,在新增記錄時(shí)可以看到也提供了反向映射,這樣做的好處是在減少后期檢索時(shí)比較地址的成本,最后通過(guò)emit觸發(fā)池子創(chuàng)建事件
///inheritdoc IUniswapV3Factory
function createPool(
address tokenA,
address tokenB,
uint24 fee
)external override noDelegateCall returns(address pool){
require(tokenA!=tokenB);
(address token0,address token1)=tokenA<tokenB?(tokenA,tokenB):(tokenB,tokenA);
require(token0!=address(0));
int24 tickSpacing=feeAmountTickSpacing[fee];
require(tickSpacing!=0);流程及源碼模式I35詳細(xì)7O98開(kāi)發(fā)O7I8
require(getPool[token0][token1][fee]==address(0));
pool=deploy(address(this),token0,token1,fee,tickSpacing);
getPool[token0][token1][fee]=pool;
//populate mapping in the reverse direction,deliberate choice to avoid the cost of comparing addresses
getPool[token1][token0][fee]=pool;
emit PoolCreated(token0,token1,fee,tickSpacing,pool);
}開(kāi)發(fā)需求及模式:MrsFu123
之后的setOwner函數(shù)用于更新工廠合約的owner,該函數(shù)只能由合約的owner調(diào)用,在更新時(shí)通過(guò)emit來(lái)觸發(fā)owner變更事件:
///inheritdoc IUniswapV3Factory
function setOwner(address _owner)external override{
require(msg.sender==owner);
emit OwnerChanged(owner,_owner);
owner=_owner;
}