DAPP农场养成种植/种树游戏链游系统开发(项目案例)丨区块链DAPP农场养成游戏源码版
简单来说,DAPP和普通的App原理一样,除了他们是完全去中心化的,由类似以太坊网络本身自己的节点来运作的DAPP,不依赖于任何中心化的服务器,DAPP是去中心化的,可以完全自动地运行。
DAPP是Decentralized Application的缩写,中文叫分布式应用/去中心化应用,通常来说,不同的DAPP会采用不同的底层区块链开发平台和共识机制,Alternatively,you can publish your own tokens(or use universal tokens based on the same blockchain platform).
function createAndInitializePoolIfNecessary(
address tokenA,
address tokenB,
uint24 fee,
uint160 sqrtPriceX96
)external payable returns(address pool){
pool=IUniswapV3Factory(factory).getPool(tokenA,tokenB,fee);
if(pool==address(0)){
pool=IUniswapV3Factory(factory).createPool(tokenA,tokenB,fee);
IUniswapV3Pool(pool).initialize(sqrtPriceX96);
}else{
(uint160 sqrtPriceX96Existing,,,,,,)=IUniswapV3Pool(pool).slot0();
if(sqrtPriceX96Existing==0){
IUniswapV3Pool(pool).initialize(sqrtPriceX96);
}
}
}
contract UniswapV3Factory is IUniswapV3Factory,UniswapV3PoolDeployer,NoDelegateCall{
...
mapping(address=>mapping(address=>mapping(uint24=>address)))public override getPool;
...
}
function deploy(
address factory,
address token0,
address token1,
uint24 fee,
int24 tickSpacing
)internal returns(address pool){
parameters=Parameters({factory:factory,token0:token0,token1:token1,fee:fee,tickSpacing:tickSpacing});
pool=address(new UniswapV3Pool{salt:keccak256(abi.encode(token0,token1,fee))}());
delete parameters;
}