DAPP流动性质押项目算力分红挖矿系统开发详细案例及源码
智能合约dapp开发技术主要由以太坊区块链网络提供支持,该网络提供了一系列的智能合约技术,这些智能合约可以让开发者快速、安全地构建出功能强大的dapp。智能合约dapp开发技术主要包括以太坊智能合约语言Solidity,以太坊智能合约框架Truffle,Web3.js,以太坊区块链浏览器Mist等
智能合约:它们是存储在区块链上的计算机程序,在满足预定条件时运行,智能合约是用Solidity语言编写的。
Solidity:一种用于编写智能合约的面向对象的编程语言。它用于在各种区块链平台上实施智能合约,最著名的是以太坊。Solidity的语法类似于JavaScript。
string memory _tokenURI=_tokenURIs[tokenId];
string memory base=_baseURI();
//If there is no base URI,return the token URI.
if(bytes(base).length==0){
return _tokenURI;
}
//If both are set,concatenate the baseURI and tokenURI(via abi.encodePacked).
if(bytes(_tokenURI).length>0){
return string(abi.encodePacked(base,_tokenURI));
}
//If there is a baseURI but no tokenURI,concatenate the tokenID to the baseURI.
return
string(abi.encodePacked(base,tokenId.toString(),baseExtension));
}
//internal
function _baseURI()internal view virtual override returns(string memory){
return baseURI;
}
//only owner
function flipSaleActive()public onlyOwner{
_isSaleActive=!_isSaleActive;
}
function flipReveal()public onlyOwner{
_revealed=!_revealed;
}
function setMintPrice(uint256 _mintPrice)public onlyOwner{
mintPrice=_mintPrice;
}
function setNotRevealedURI(string memory _notRevealedURI)public onlyOwner{
notRevealedUri=_notRevealedURI;
}
function setBaseURI(string memory _newBaseURI)public onlyOwner{
baseURI=_newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
{
baseExtension=_newBaseExtension;
}
function setMaxBalance(uint256 _maxBalance)public onlyOwner{
maxBalance=_maxBalance;
}
function setMaxMint(uint256 _maxMint)public onlyOwner{
maxMint=_maxMint;
}
function withdraw(address to)public onlyOwner{
uint256 balance=address(this).balance;
payable(to).transfer(balance);
}
}