你每天都會用到的開發者工具,全都集中在同一個地方。

轉換器、格式化工具、雜湊、驗證器,以及那些你總是一再重開的小工具,都留在一起,不再散落在各個分頁裡。

GitHub
/ 工具
/ 工具搜尋
109 款工具
/ 合約 Storage Slot 計算器
/ 選定的工具

合約 Storage Slot 計算器 - 免費 Web3 工具

計算 Solidity 智能合約中 mapping 與陣列的 storage slot

01

甚麼是儲存槽?

在以太坊智慧合約中,儲存被組織成 32 位元組的槽。每個狀態變數佔用一個特定的槽,而 mapping 則使用依鍵與基底槽編號計算出的槽。

02

運作原理是甚麼?

對於 mapping,儲存槽的計算方式為:keccak256(key . slot),其中 key 是 mapping 的鍵(填補至 32 位元組),slot 是 mapping 的基底槽編號。// 範例:計算 balances[user] 的槽 con…

03

範例情境

涵蓋 ERC-20 餘額 mapping、NFT 擁有者 mapping(uint256 鍵)與巢狀 mapping,讓你能快速比較常見的輸入與輸出。

/ 相關工具
/ 程式碼

選定工具的原始碼,與右側的即時版本並列顯示。

/ 原始碼
TypeScript
typescript
// npm install viem

import { keccak256, encodePacked, pad, toHex } from 'viem';

// Calculate storage slot for mapping
function getMappingSlot(key: string, slotNumber: number): string {
  let keyBytes: `0x${string}`;

  // Handle address (20 bytes) or uint256 (32 bytes)
  if (key.startsWith('0x')) {
Buidl Now 圖示

把所有實用工具集中在一處,讓你專注在開發流程中。

挑一個工具、完成檢查、複製你需要的內容,然後回到真正的產品工作上。

為講求快速交付的建構者打造的開發者工具。© 2026 Buidl Now. 保留所有權利。