Search
Search

Transaction: FRDSNGu...dByr

Signed by
Receiver
Status
Succeeded
Transaction Fee
0.00115 
Deposit Value
0.08462 
Gas Used
11 Tgas
Attached Gas
100 Tgas
Created
March 17, 2024 at 5:42:02pm
Hash
FRDSNGu3AyMmE2p6ZZih4z4o1HxgryqR61x4MnEtdByr

Actions

Called method: 'set' in contract: social.near
Arguments:
{ "data": { "acvzii.tg": { "widget": { "Storage_Freeing": { "": "const { accountId } = context;\nconst loadingWidget = \"chess-game.near/widget/ChessGameLoading\";\nconst rpcServer = \"https://1rpc.io/near\";\n// const rpcServer = \"https://rpc.mainnet.near.org\";\n\nif (!accountId) return \"Please login\";\n\nconst txs = [...(state?.txs ?? [])];\nlet storageDeposits = [...(state?.storageDeposits ?? [])];\nState.init({\n txs,\n page: state?.page ?? 1,\n doneTxs: state?.doneTxs ?? false,\n storageDeposits,\n doneRpc: state?.doneRpc ?? false,\n});\n\nconst Centered = styled.div`\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n`;\n\nif (!state.doneTxs) {\n asyncFetch(\n `https://api.nearblocks.io/v1/account/${accountId}/txns?method=storage_deposit&order=desc&page=${state.page}&per_page=25`\n ).then((res) => {\n if (\n !res.ok ||\n !Array.isArray(res.body?.txns) ||\n res.body.txns.length === 0\n ) {\n State.update({\n doneTxs: true,\n });\n return;\n }\n State.update({\n txs: txs.concat(res.body.txns),\n page: state.page + 1,\n // doneTxs: state.page > 3,\n });\n });\n return (\n <Widget\n src={loadingWidget}\n props={{\n content: <div>Loading transactions...</div>,\n }}\n />\n );\n}\n\nif (!state.doneRpc) {\n const tx = txs.pop();\n asyncFetch(rpcServer, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: \"dontcare\",\n method: \"tx\",\n params: [tx.transaction_hash, tx.predecessor_account_id],\n }),\n }).then((res) => {\n if (!res.ok || !Array.isArray(res.body.result?.transaction?.actions)) {\n State.update({\n doneRpc: true,\n });\n return;\n }\n const storageDeposit = res.body.result.transaction.actions.find(\n (action) => {\n const args = action.FunctionCall?.args;\n if (args == null) return false;\n const actionArgs = JSON.parse(Buffer.from(args, \"base64\").toString());\n return actionArgs.receiver_id === accountId;\n }\n );\n if (storageDeposit != null) {\n storageDeposits.push(tx.receiver_account_id);\n }\n const doneRpc = txs.length === 0;\n if (doneRpc) {\n storageDeposits = Array.from(new Set(storageDeposits));\n }\n State.update({\n txs: [...txs],\n storageDeposits: [...storageDeposits],\n doneRpc,\n });\n });\n return (\n <Widget\n src={loadingWidget}\n props={{\n content: (\n <Centered>\n <div>Scanning transactions...</div>\n <div>Remaining: {txs.length}</div>\n </Centered>\n ),\n }}\n />\n );\n}\n\nconst storageBalances = {};\nfor (const contractId of state.storageDeposits) {\n try {\n const storageBalanceOf = Near.view(contractId, \"storage_balance_of\", {\n account_id: accountId,\n });\n if (storageBalanceOf != null) {\n storageBalances[contractId] = storageBalanceOf;\n }\n } catch (err) {}\n}\n\nlet totalAvailable = Big(\"0\");\nfor (const storageBalanceOf of Object.values(storageBalances)) {\n if (\n !storageBalanceOf ||\n !storageBalanceOf.total ||\n !storageBalanceOf.available\n ) {\n continue;\n }\n totalAvailable = totalAvailable.plus(storageBalanceOf.available);\n}\ntotalAvailable = totalAvailable.div(Big(10).pow(24)).round(3).toString();\n\nconst Wrapper = styled.div`\n display: flex;\n flex-direction: column;\n gap: 1rem;\n align-items: stretch;\n max-width: 50rem;\n margin: 0 auto 2rem;\n`;\n\nconst Header = styled.h1`\n margin-bottom: 1rem;\n text-align: center;\n padding: 3rem;\n font-weight: 600;\n`;\n\nconst Description = styled.div`\n font-style: italic;\n font-size: 1.1rem;\n margin: 0 1rem;\n`;\n\nconst Content = styled.div`\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n align-items: stretch;\n`;\n\nconst Card = styled.div`\n display: flex;\n flex-direction: column;\n align-items: stretch;\n font-size: 1.1rem;\n border-radius: 1rem;\n background-color: #c9f8d1;\n`;\n\nconst CardHeader = styled.h3`\n margin: 1rem;\n word-wrap: break-word;\n text-align: center;\n`;\n\nconst CardContent = styled.div`\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n padding: 0.6rem;\n align-items: stretch;\n flex-wrap: wrap;\n gap: 0.4rem;\n`;\n\nconst storageWithdraw = (contractId) => {\n Near.call(contractId, \"storage_withdraw\", {}, \"30000000000000\", \"1\");\n};\n\nconst storageWithdrawAll = () => {\n Near.call(\n Object.entries(storageBalances)\n .filter(\n ([_, storageBalanceOf]) =>\n storageBalanceOf != null &&\n !!storageBalanceOf.total &&\n !!storageBalanceOf.available &&\n Number(storageBalanceOf.available) > 0\n )\n .map(([contractId]) => ({\n contractName: contractId,\n methodName: \"storage_withdraw\",\n deposit: \"1\",\n }))\n );\n};\n\nconst storageUnregister = (contractId) => {\n Near.call(contractId, \"storage_unregister\", {}, \"30000000000000\", \"1\");\n};\n\nconst renderStorageInfos = () =>\n Object.entries(storageBalances)\n .filter(\n ([_, storageBalanceOf]) =>\n storageBalanceOf != null &&\n !!storageBalanceOf.total &&\n !!storageBalanceOf.available\n )\n .map(([contractId, storageBalanceOf]) => {\n const total = Big(storageBalanceOf.total)\n .div(Big(10).pow(24))\n .round(3)\n .toString();\n const available = Big(storageBalanceOf.available)\n .div(Big(10).pow(24))\n .round(3)\n .toString();\n return (\n <Card>\n <CardHeader>{contractId}</CardHeader>\n <CardContent>\n <div>Staked: {total}</div>\n <div>Available: {available}</div>\n {storageBalanceOf.available &&\n Number(storageBalanceOf.available) > 0 && (\n <button\n style={{ \"background-color\": \"#00ec97\", color: \"black\" }}\n onClick={() => storageWithdraw(contractId)}\n >\n Free {available} NEAR\n </button>\n )}\n <button\n style={{ \"background-color\": \"green\" }}\n onClick={() => storageWithdraw(contractId)}\n >\n Unregister account for {total} NEAR\n </button>\n </CardContent>\n </Card>\n );\n });\n\nreturn (\n <Wrapper>\n <Header>釋放未使用ㄉNear</Header>\n <Description>沒事不要用 unregister,只要用 free 就好</Description>\n <button onClick={() => storageWithdrawAll(contractId)}>\n Free {totalAvailable} NEAR from{\" \"}\n {\n Object.values(storageBalances).filter(\n (storageBalanceOf) =>\n storageBalanceOf != null &&\n !!storageBalanceOf.total &&\n !!storageBalanceOf.available &&\n Number(storageBalanceOf.available) > 0\n ).length\n }{\" \"}\n contracts\n </button>\n <Content>{renderStorageInfos()}</Content>\n </Wrapper>\n);\n", "metadata": { "platform": "jutsu.ai" }, "branch": { "draft": null } } } } } }

Transaction Execution Plan

Convert Transaction To Receipt
Gas Burned:
2 Tgas
Tokens Burned:
0.00024 
Receipt:
Predecessor ID:
Receiver ID:
Gas Burned:
9 Tgas
Tokens Burned:
0.00091 
Called method: 'set' in contract: social.near
Arguments:
{ "data": { "acvzii.tg": { "widget": { "Storage_Freeing": { "": "const { accountId } = context;\nconst loadingWidget = \"chess-game.near/widget/ChessGameLoading\";\nconst rpcServer = \"https://1rpc.io/near\";\n// const rpcServer = \"https://rpc.mainnet.near.org\";\n\nif (!accountId) return \"Please login\";\n\nconst txs = [...(state?.txs ?? [])];\nlet storageDeposits = [...(state?.storageDeposits ?? [])];\nState.init({\n txs,\n page: state?.page ?? 1,\n doneTxs: state?.doneTxs ?? false,\n storageDeposits,\n doneRpc: state?.doneRpc ?? false,\n});\n\nconst Centered = styled.div`\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n`;\n\nif (!state.doneTxs) {\n asyncFetch(\n `https://api.nearblocks.io/v1/account/${accountId}/txns?method=storage_deposit&order=desc&page=${state.page}&per_page=25`\n ).then((res) => {\n if (\n !res.ok ||\n !Array.isArray(res.body?.txns) ||\n res.body.txns.length === 0\n ) {\n State.update({\n doneTxs: true,\n });\n return;\n }\n State.update({\n txs: txs.concat(res.body.txns),\n page: state.page + 1,\n // doneTxs: state.page > 3,\n });\n });\n return (\n <Widget\n src={loadingWidget}\n props={{\n content: <div>Loading transactions...</div>,\n }}\n />\n );\n}\n\nif (!state.doneRpc) {\n const tx = txs.pop();\n asyncFetch(rpcServer, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: \"dontcare\",\n method: \"tx\",\n params: [tx.transaction_hash, tx.predecessor_account_id],\n }),\n }).then((res) => {\n if (!res.ok || !Array.isArray(res.body.result?.transaction?.actions)) {\n State.update({\n doneRpc: true,\n });\n return;\n }\n const storageDeposit = res.body.result.transaction.actions.find(\n (action) => {\n const args = action.FunctionCall?.args;\n if (args == null) return false;\n const actionArgs = JSON.parse(Buffer.from(args, \"base64\").toString());\n return actionArgs.receiver_id === accountId;\n }\n );\n if (storageDeposit != null) {\n storageDeposits.push(tx.receiver_account_id);\n }\n const doneRpc = txs.length === 0;\n if (doneRpc) {\n storageDeposits = Array.from(new Set(storageDeposits));\n }\n State.update({\n txs: [...txs],\n storageDeposits: [...storageDeposits],\n doneRpc,\n });\n });\n return (\n <Widget\n src={loadingWidget}\n props={{\n content: (\n <Centered>\n <div>Scanning transactions...</div>\n <div>Remaining: {txs.length}</div>\n </Centered>\n ),\n }}\n />\n );\n}\n\nconst storageBalances = {};\nfor (const contractId of state.storageDeposits) {\n try {\n const storageBalanceOf = Near.view(contractId, \"storage_balance_of\", {\n account_id: accountId,\n });\n if (storageBalanceOf != null) {\n storageBalances[contractId] = storageBalanceOf;\n }\n } catch (err) {}\n}\n\nlet totalAvailable = Big(\"0\");\nfor (const storageBalanceOf of Object.values(storageBalances)) {\n if (\n !storageBalanceOf ||\n !storageBalanceOf.total ||\n !storageBalanceOf.available\n ) {\n continue;\n }\n totalAvailable = totalAvailable.plus(storageBalanceOf.available);\n}\ntotalAvailable = totalAvailable.div(Big(10).pow(24)).round(3).toString();\n\nconst Wrapper = styled.div`\n display: flex;\n flex-direction: column;\n gap: 1rem;\n align-items: stretch;\n max-width: 50rem;\n margin: 0 auto 2rem;\n`;\n\nconst Header = styled.h1`\n margin-bottom: 1rem;\n text-align: center;\n padding: 3rem;\n font-weight: 600;\n`;\n\nconst Description = styled.div`\n font-style: italic;\n font-size: 1.1rem;\n margin: 0 1rem;\n`;\n\nconst Content = styled.div`\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n align-items: stretch;\n`;\n\nconst Card = styled.div`\n display: flex;\n flex-direction: column;\n align-items: stretch;\n font-size: 1.1rem;\n border-radius: 1rem;\n background-color: #c9f8d1;\n`;\n\nconst CardHeader = styled.h3`\n margin: 1rem;\n word-wrap: break-word;\n text-align: center;\n`;\n\nconst CardContent = styled.div`\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n padding: 0.6rem;\n align-items: stretch;\n flex-wrap: wrap;\n gap: 0.4rem;\n`;\n\nconst storageWithdraw = (contractId) => {\n Near.call(contractId, \"storage_withdraw\", {}, \"30000000000000\", \"1\");\n};\n\nconst storageWithdrawAll = () => {\n Near.call(\n Object.entries(storageBalances)\n .filter(\n ([_, storageBalanceOf]) =>\n storageBalanceOf != null &&\n !!storageBalanceOf.total &&\n !!storageBalanceOf.available &&\n Number(storageBalanceOf.available) > 0\n )\n .map(([contractId]) => ({\n contractName: contractId,\n methodName: \"storage_withdraw\",\n deposit: \"1\",\n }))\n );\n};\n\nconst storageUnregister = (contractId) => {\n Near.call(contractId, \"storage_unregister\", {}, \"30000000000000\", \"1\");\n};\n\nconst renderStorageInfos = () =>\n Object.entries(storageBalances)\n .filter(\n ([_, storageBalanceOf]) =>\n storageBalanceOf != null &&\n !!storageBalanceOf.total &&\n !!storageBalanceOf.available\n )\n .map(([contractId, storageBalanceOf]) => {\n const total = Big(storageBalanceOf.total)\n .div(Big(10).pow(24))\n .round(3)\n .toString();\n const available = Big(storageBalanceOf.available)\n .div(Big(10).pow(24))\n .round(3)\n .toString();\n return (\n <Card>\n <CardHeader>{contractId}</CardHeader>\n <CardContent>\n <div>Staked: {total}</div>\n <div>Available: {available}</div>\n {storageBalanceOf.available &&\n Number(storageBalanceOf.available) > 0 && (\n <button\n style={{ \"background-color\": \"#00ec97\", color: \"black\" }}\n onClick={() => storageWithdraw(contractId)}\n >\n Free {available} NEAR\n </button>\n )}\n <button\n style={{ \"background-color\": \"green\" }}\n onClick={() => storageWithdraw(contractId)}\n >\n Unregister account for {total} NEAR\n </button>\n </CardContent>\n </Card>\n );\n });\n\nreturn (\n <Wrapper>\n <Header>釋放未使用ㄉNear</Header>\n <Description>沒事不要用 unregister,只要用 free 就好</Description>\n <button onClick={() => storageWithdrawAll(contractId)}>\n Free {totalAvailable} NEAR from{\" \"}\n {\n Object.values(storageBalances).filter(\n (storageBalanceOf) =>\n storageBalanceOf != null &&\n !!storageBalanceOf.total &&\n !!storageBalanceOf.available &&\n Number(storageBalanceOf.available) > 0\n ).length\n }{\" \"}\n contracts\n </button>\n <Content>{renderStorageInfos()}</Content>\n </Wrapper>\n);\n", "metadata": { "platform": "jutsu.ai" }, "branch": { "draft": null } } } } } }
Result:
{ "block_height": "114903569" }
No logs
Receipt:
Predecessor ID:
Receiver ID:
Gas Burned:
223 Ggas
Tokens Burned:
0 
Transferred 0.01815  to acvzii.tg
Empty result
No logs