diff --git a/packages/client/src/mud/createSystemCalls.ts b/packages/client/src/mud/createSystemCalls.ts index 824bbdd2..f8613803 100644 --- a/packages/client/src/mud/createSystemCalls.ts +++ b/packages/client/src/mud/createSystemCalls.ts @@ -82,9 +82,9 @@ export function createSystemCalls( } } - const selectUserNft = async (tokenId: any, address: any) => { + const selectUserNft = async (tokenId: any, address: any, nonce: any) => { try { - const tx = await worldContract.write.selectUserNft([tokenId]); + const tx = await worldContract.write.selectUserNft([tokenId], {nonce}); await waitForTransaction(tx); return getComponentValue(Player, encodeEntity({ addr: "address" }, { addr: address})); } catch (error) { @@ -93,9 +93,9 @@ export function createSystemCalls( } } - const selectLootNFT = async (tokenId: any, address: any) => { + const selectLootNFT = async (tokenId: any, address: any, nonce: any) => { try { - const tx = await worldContract.write.selectLootNFT([tokenId]); + const tx = await worldContract.write.selectLootNFT([tokenId], {nonce}); await waitForTransaction(tx); let LootList1Data = getComponentValue(LootList1, encodeEntity({ addr: "address" }, { addr: address})); let LootList2Data = getComponentValue(LootList2, encodeEntity({ addr: "address" }, { addr: address})); diff --git a/packages/client/src/pages/home/index.tsx b/packages/client/src/pages/home/index.tsx index 972bda78..5a986d20 100644 --- a/packages/client/src/pages/home/index.tsx +++ b/packages/client/src/pages/home/index.tsx @@ -185,8 +185,9 @@ const Home = () => { lootUrl = atobUrl(lootUrl) setUserUrl(url.image) setLootUrl(lootUrl.image) - - let rep = await Promise.all([selectUserNft(userTokenId, network.account), selectLootNFT(lootTokenId, network.account)]) + let nonce = await network.publicClient.getTransactionCount({address: network.account}) + console.log(nonce, 'nonce') + let rep = await Promise.all([selectUserNft(userTokenId, network.account, nonce), selectLootNFT(lootTokenId, network.account, nonce + 1)]) console.log(rep, 'rep') let playerData = rep[0] let lootData = rep[1]