
5

请问有没有参考的盲盒智能合约? | 登链社区 | 技术问答
source link: https://learnblockchain.cn/question/2724
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

请问有没有参考的盲盒智能合约? | 登链社区 | 技术问答
9 请问有没有参考的盲盒智能合约?
回答问题即可获得 5 经验值,回答被采纳后即可获得 14 学分。
温柔
1小时前
function addBoxFactory(
uint8 bunnyId,
string memory tokenURI,
uint256 limit
) public onlyOwner returns (uint256) {
_boxFactoriesId++;
BoxFactory memory boxFactory;
boxFactory.id = _boxFactoriesId;
boxFactory.bunnyId = bunnyId;
boxFactory.tokenURI = tokenURI;
boxFactory.price = boxPrice;
boxFactory.limit = limit;
_boxFactories[_boxFactoriesId] = boxFactory;
return _boxFactoriesId;
}
温柔
1小时前
请问大佬如何实现一个方法,可以公平产出A或B,而且保证A和B的数量不能多也不能少。概率
function buyRandomBox() external payable nonReentrant returns(uint256 tokenId) {
// @????? 这里要怎么实现 公平随机决定 产出A还是B
// uint256 factoryIdAorB??? = Random()????
BoxFactory storage boxFactory = _boxFactories[factoryId];
if (boxFactory.limit > 0) {
require(
boxFactory.limit.sub(boxFactory.minted) >= 1,
"Over the limit"
);
}
// 买一个生产一个box
boxFactory.minted = boxFactory.minted.add(1);
// 生产
tokenId = factory.nft.mint(msg.sender, boxFactory.tokenURI, boxFactory.bunnyId);
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK