Address Registry: Source of Truth
Address Registry Audit Certificate: The Dynamic Source of Truth
Issued by: D-Safe Internal Auditing
This technical briefing details the architectural shift from static, build-time configurations to a dynamic, on-chain Registry system for the vue.datapond.earth dApp. By querying the blockchain directly via Public RPCs, the system achieves frictionless “Flash Boot” capabilities. Currently managed by a single admin entity with a roadmap to transition to an institutional Multi-Sig, this registry serves as the certified, decentralized index for metadata management.
1. Smart Contract: AddressRegistry.sol
The AddressRegistry contract serves as the “Source of Truth” for the entire D-Library ecosystem. Originally designed to track contract addresses and ABIs, it has evolved into a generic data registry.
Key Enhancements
Generic String Storage
To avoid hardcoding Arweave URLs or configuration strings in the frontend, we introduced a generic history-tracking mechanism for arbitrary data keys.
New API Methods
addData(string key, string value): Allows administrators to push new versions of data.getLatestData(string key): Retrieves the current active version of a specific data key.getAllDataKeys(): Enables clients to discover all available data keys.
Intelligent ABI Caching (Immutable by Design)
To minimize network requests to Arweave, the loader leverages the immutability of decentralized storage.
📄 Full Contract Source: AddressRegistry.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.24;
/**
* @title Address Registry
* @dev An immutable registry that stores the historical and active deployment addresses for
* D-Library Core Contracts (Factory, BouncerStorage, BackupStorage, etc.).
* Designed to replace build-time static configuration.
*/
contract AddressRegistry {
address public admin;
struct ContractRecord {
address contractAddress;
string abiUrl;
}
// Mapping from Contract Name (e.g., "Factory") to a historical array of deployed records
mapping(string => ContractRecord[]) private _contractHistory;
// Array to keep track of all registered contract names for easy enumeration
string[] private _contractNames;
// Mapping to prevent duplicates in _contractNames
mapping(string => bool) private _nameExists;
// Mapping from a data key (e.g., "EN_TOPICS") to a historical array of string values
mapping(string => string[]) private _dataHistory;
// Array to keep track of all registered data keys
string[] private _dataKeys;
// Mapping to prevent duplicates in _dataKeys
mapping(string => bool) private _dataKeyExists;
event ContractAdded(
string indexed name,
address indexed contractAddress,
string abiUrl,
uint256 version
);
event DataAdded(
string indexed key,
string value,
uint256 version
);
event AdminChanged(address indexed oldAdmin, address indexed newAdmin);
modifier onlyAdmin() {
require(
msg.sender == admin,
"AddressRegistry: caller is not the admin"
);
_;
}
constructor() {
admin = msg.sender;
}
/**
* @dev Transfers administration of the registry to a new address.
*/
function changeAdmin(address newAdmin) external onlyAdmin {
require(
newAdmin != address(0),
"AddressRegistry: new admin is the zero address"
);
emit AdminChanged(admin, newAdmin);
admin = newAdmin;
}
/**
* @dev Appends a new deployed address to the history of a given contract name.
* The last appended address is considered the "active" or "latest" version.
*/
function addContract(
string memory name,
address contractAddress,
string memory abiUrl
) external onlyAdmin {
require(
contractAddress != address(0),
"AddressRegistry: contract address cannot be zero"
);
require(
bytes(name).length > 0,
"AddressRegistry: contract name cannot be empty"
);
if (!_nameExists[name]) {
_nameExists[name] = true;
_contractNames.push(name);
}
_contractHistory[name].push(
ContractRecord({contractAddress: contractAddress, abiUrl: abiUrl})
);
uint256 versionIndex = _contractHistory[name].length; // 1-indexed version
emit ContractAdded(name, contractAddress, abiUrl, versionIndex);
}
/**
* @dev Appends a new string value to the history of a given data key.
* The last appended value is considered the "active" or "latest" version.
*/
function addData(
string memory key,
string memory value
) external onlyAdmin {
require(
bytes(key).length > 0,
"AddressRegistry: data key cannot be empty"
);
require(
bytes(value).length > 0,
"AddressRegistry: data value cannot be empty"
);
if (!_dataKeyExists[key]) {
_dataKeyExists[key] = true;
_dataKeys.push(key);
}
_dataHistory[key].push(value);
uint256 versionIndex = _dataHistory[key].length; // 1-indexed version
emit DataAdded(key, value, versionIndex);
}
/**
* @dev Returns the most recently deployed (active) address for a given contract name.
* Reverts if the contract name has no history.
*/
function getLatestContract(
string memory name
) external view returns (address, string memory) {
require(
_contractHistory[name].length > 0,
"AddressRegistry: contract not found"
);
ContractRecord memory record = _contractHistory[name][
_contractHistory[name].length - 1
];
return (record.contractAddress, record.abiUrl);
}
/**
* @dev Returns the most recently added value for a given data key.
* Reverts if the data key has no history.
*/
function getLatestData(
string memory key
) external view returns (string memory) {
require(
_dataHistory[key].length > 0,
"AddressRegistry: data not found"
);
return _dataHistory[key][_dataHistory[key].length - 1];
}
/**
* @dev Returns the entire chronological history of records for a given contract name.
* The last record in the array is the current active version.
*/
function getContractHistory(
string memory name
) external view returns (ContractRecord[] memory) {
return _contractHistory[name];
}
/**
* @dev Returns the entire chronological history of strings for a given data key.
*/
function getDataHistory(
string memory key
) external view returns (string[] memory) {
return _dataHistory[key];
}
/**
* @dev Returns all recognized contract names currently tracked in the registry.
*/
function getAllContractNames() external view returns (string[] memory) {
return _contractNames;
}
/**
* @dev Returns all recognized data keys currently tracked in the registry.
*/
function getAllDataKeys() external view returns (string[] memory) {
return _dataKeys;
}
} Build with Indestructible Infrastructure
Our D-SAFE certification ensures your smart contracts meet the highest standards of technical permanence and ethical safety.
Consult with our Architects