Stepn跑鞋跑步鏈遊趣步模式系統開發詳情規則/方案詳細/原始碼案例
Web3.0的特點是使用區塊鏈和其他賦能技術,如AI和密碼學,以建立一個更公平、安全和私有的線上生態系統。
web3.0的發展趨勢是建立分散的網路、協議和應用程式,以無信任和安全的方式促進價值和資訊的交換。
智慧合約dapp開發技術主要由以太坊區塊鏈網路提供支援,搭建原始碼案例:Mrsfu123 該網路提供了一系列的智慧合約技術,這些智慧合約可以讓開發者快速、安全地構建出功能強大的dapp。智慧合約dapp開發技術主要包括以太坊智慧合約語言Solidity,以太坊智慧合約框架Truffle,Web3.js,以太坊區塊鏈瀏覽器Mist等
Single player mode is currently the only mode that has been activated.In this mode,users can generate GST and GMT based on the number of steps they take(GMT acquisition has not yet been enabled).The conversion ratio of steps and tokens is influenced by a series of parameters:the higher the"efficiency"coefficient of running shoes,the more GST generated per step;The higher the'comfort'coefficient,the more GMT generated per step.In addition,the speed of walking also has an impact.Only when the speed reaches a certain level can income be generated,and the faster the speed,the higher the income.Users may also obtain a"mysterious box"during the running process,from which they can randomly draw different levels of gemstones.Users can embed gemstones on running shoes by consuming GST to enhance their attributes.
(1)The Game Mechanism of StepN
The main concept of StepN is"Move to Earn"(M2E).When it comes to this concept,veteran readers should easily associate it with the metaverse product Axie Infinity that I mentioned in my column-the main concept of this product is"Play to Earn"(P2E),which means that users can earn income while playing.To a large extent,StepN is actually an Axie Infinity with a sports vest.
In Axie Infinity,players need to first purchase an NFT for their pet(Axie),and then they can cultivate the pet and engage it in battles and competitions to earn income.In StepN,this design was basically followed,except that the pet Axie in Axie Infinity was replaced with running shoes,and the method of earning income changed from virtual battles in the game to running in reality.
According to StepN's settings,users need to have a pair of"running shoes"NFTs before entering the game.In the game,there are multiple types of running shoes initially provided,and each type of running shoe has corresponding"efficiency"and"comfort"attributes,which will affect the number of tokens players will obtain from sports in the future.Of course,the more advanced the properties of running shoes,the better,and the more expensive the price.Players can directly purchase according to their own needs,or they can purchase a blind box and randomly select a pair of running shoes from it.
After the player has a pair of running shoes,they can start the game.In the StepN white paper,three game modes are listed:Solo Mode,Marathon Mode,and Background Mode.
Single player mode is currently the only mode that has been activated.In this mode,users can generate GST and GMT based on the number of steps they take(GMT acquisition has not yet been enabled).The conversion ratio of steps and tokens is influenced by a series of parameters:the higher the"efficiency"coefficient of running shoes,the more GST generated per step;The higher the'comfort'coefficient,the more GMT generated per step.In addition,the speed of walking also has an impact.Only when the speed reaches a certain level can income be generated,and the faster the speed,the higher the income.Users may also obtain a"mysterious box"during the running process,from which they can randomly draw different levels of gemstones.Users can embed gemstones on running shoes by consuming GST to enhance their attributes.
NFT轉移階段,該階段的邏輯大致如下:
修正轉移雙方的balance引數
--_packedAddressData[from];
++_packedAddressData[to];
更新tokenId對應的_packedOwnerships資料:
_packedOwnerships[tokenId]=_packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED|_nextExtraData(from,to,prevOwnershipPacked)
);
由於轉移過程必須進行初始化,所以此處將轉移的NFT的nextInitialized設定為True
考慮下一個NFT是否被初始化,
如轉移下圖中tokenId=3的NFT:
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片儲存下來直接上傳(img-wKsxnwNP-1675684640935)
該NFT轉移後,由於破壞了擁有者0x2的連續性,所以我們需要重寫tokenId=4的對應資料,程式碼如下:
if(prevOwnershipPacked&_BITMASK_NEXT_INITIALIZED==0){
uint256 nextTokenId=tokenId+1;
if(_packedOwnerships[nextTokenId]==0){
if(nextTokenId!=_currentIndex){
_packedOwnerships[nextTokenId]=prevOwnershipPacked;
}
}
此處使用了_packedOwnerships[nextTokenId]==0排除了tokenId=4轉移的特殊情況。該NFT位於連續NFT的末尾,轉移此NFT不會破環連續性
至此,我們完成了NFT的轉移的核心流程。接下來就是已經介紹過的Transfer釋放流程:
uint256 toMasked=uint256(uint160(to))&_BITMASK_ADDRESS;
assembly{
//Emit the`Transfer`event.
log4(
0,//Start of data(0,since no data).
0,//End of data(0,since no data).
_TRANSFER_EVENT_SIGNATURE,//Signature.
from,//`from`.
toMasked,//`to`.
tokenId//`tokenId`.
)
}
if(toMasked==0)_revert(TransferToZeroAddress.selector);
safeTransferFrom作為transferFrom的安全版本,該函式只是增加了_checkContractOnERC721Received檢測,此檢測函式已在上文進行了介紹,此處不再贅述。
銷燬
burn銷燬的核心函式為_burn函式,由於銷燬事實上相當於將NFT轉移給0地址,所以其大量邏輯與transfer類似。
_burn函式定義如下:
function _burn(uint256 tokenId,bool approvalCheck)internal virtual
1
引數含義如下:
tokenId待銷燬NFT的tokenId
approvalCheck是否檢測函式呼叫者的許可權
大致流程如下:
獲取待銷燬NFT擁有者的資訊
如果設定approvalCheck為true則檢測函式呼叫者的相關許可權
清空待銷燬NFT的授權approve資料
減少擁有者的balance
在_packedOwnerships中寫入銷燬資訊
恢復代幣連續性
釋放事件
接下來,我們詳細分析具體的程式碼實現:
uint256 prevOwnershipPacked=_packedOwnershipOf(tokenId);
address from=address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot,address approvedAddress)=_getApprovedSlotAndAddress(tokenId);
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69956839/viewspace-2948414/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Stepn跑鞋/NFT跑鞋/鏈遊跑步運動專案/系統開發/案例詳情/規則方案/原始碼版原始碼
- DAPP/Stepn跑鞋鏈遊跑步運動模式/系統開發/技術案例/方案詳細/規則及原始碼APP模式原始碼
- Stepn跑鞋跑步鏈遊系統開發/趣步系統開發/詳情案例/成熟技術/原始碼版原始碼
- Stepn跑鞋跑步運動鏈遊專案系統開發(開發案例)/方案詳細/原始碼部署原始碼
- Stepn跑鞋系統開發/NFT跑步運動模式/鏈遊開發/詳細案例/成熟技術/原始碼版模式原始碼
- Stepn/NFT跑鞋跑步鏈遊系統開發/技術詳解/規則及玩法/原始碼成熟原始碼
- Stepn跑鞋跑步運動系統開發/鏈遊開發/玩法規則/技術方案/原始碼原始碼
- Dapp/Stepn跑鞋鏈遊系統開發詳細技術案例/成熟方案/原始碼功能APP原始碼
- NFT/Stepn跑鞋鏈遊專案/系統開發/方案詳細/技術詳情/原始碼說明原始碼
- STEPN跑鞋跑步鏈遊開發(成熟案例、原始碼交付)原始碼
- Stepn跑鞋跑步鏈遊開發穩定版,Dapp/Stepn跑鞋系統開發(玩法規則)及原始碼技術分析APP原始碼
- Stepn跑鞋鏈遊智慧合約系統開發詳情方案
- Stepn/nft跑鞋系統開發/鏈遊專案開發/技術詳細/玩法邏輯/原始碼案例原始碼
- Stepn跑鞋NFT鏈遊合成遊戲系統開發技術詳情遊戲
- NFT鏈遊/Stepn跑鞋鏈遊系統開發技術/Stepn跑鞋原始碼/Defi/NFT原始碼
- stepn跑鞋鏈遊系統開發技術說明及案例原始碼原始碼
- Stepn跑鞋(合成遊戲)NFT鏈遊合約開發系統技術詳情遊戲
- 關於STEPN跑步跑鞋NFT鏈遊開發系統搭建技術
- dapp鏈上挖礦系統開發|規則詳情|方案模式APP模式
- Stepn跑鞋鏈遊/系統技術/Stepn跑鞋開發/NFT鏈遊/應用/DAPPAPP
- Stepn跑鞋GMT系統開發|NFT鏈遊Stepn跑鞋GMT開發技術
- 紅酒鏈遊WineGometa系統模式開發原始碼詳情Go模式原始碼
- stepn跑鞋鏈遊系統開發成熟技術程式碼方案(全合約)
- 普瑞緹Protradex系統開發/DAPP合約鏈上/質押挖礦分紅/案例詳細/詳情規則/原始碼版APP原始碼
- 分投趣fintoch開發丨fintoch分投趣系統開發方案詳細丨分投趣fintoch系統原始碼案例原始碼
- Techfinger遊戲搬磚系統開發技術詳細/功能詳情/原始碼方案遊戲原始碼
- 區塊鏈遊戲系統開發(Gamefi鏈遊開發案例)丨Gamefi鏈遊系統開發詳細及原始碼區塊鏈遊戲GAM原始碼
- 關於Stepn跑步NFT鏈遊開發系統demo
- FINTOCH分趣投系統開發技術詳細及案例原始碼原始碼
- DAPP即時通訊系統開發(詳細案例)丨DAPP即時通訊系統開發(方案規則)/原始碼APP原始碼
- 電競系統開發技術詳情,掌趣電競系統開發案例(原始碼)原始碼
- NFT遊戲GameFi元宇宙(鏈遊遊戲)系統原始碼開發(詳情方案)遊戲GAM元宇宙原始碼
- DAPP區塊鏈互助公排智慧合約系統開發玩法規則/詳細案例/功能原始碼APP區塊鏈原始碼
- 雲遊世界系統模式開發詳細方案模式
- 鏈動2+1系統開發原始碼示例| 鏈動2+1系統開發模式規則詳解原始碼模式
- 鏈動2+1系統開發模式規則詳解 | 鏈動2+1系統開發原始碼示例模式原始碼
- NFT遊戲鏈遊系統開發技術詳細丨NFT遊戲鏈遊DAPP開發原始碼模式遊戲APP原始碼模式
- 區塊鏈DApp開發模式詳情 | 去中心化應用開發原始碼規則解析區塊鏈APP模式中心化原始碼