@the_library/web3-registry-addresses
v1.2.0
Published
Common package for handling Web3 AddressRegistry sessions and caching
Maintainers
Readme
@the_library/web3-registry-addresses
Welcome to the D-Library Web3 ecosystem! This package is the crucial "bridge" that connects your frontend application to the exact, certified Smart Contracts endorsed by dsafe.us for the decentralized D-Library project.
Legal Notice & D-CODE OPEN SOVEREIGN LICENCE
WARNING: PROPRIETARY PUBLIC SOURCE | D-SAFE COMPLIANT
This software is released strictly under the D-CODE OPEN SOVEREIGN LICENCE (v1.2). By utilizing this package, you agree to its binding conditions.
Critical Infrastructure Clause
As defined in Section 3: Technical Anchors & Hard-Fork Resilience of the license:
Immutable Addresses: You are prohibited from manually modifying the hard-coded Smart Contract addresses or D-SAFE Source URLs embedded in this package to point to non-certified ledgers.
Modifying the registry endpoints or overriding the canonical lookup configuration within this package to point to private, uncertified, or centralized ledgers constitutes a material breach of the provided D-CODE OPEN SOVEREIGN LICENCE.
This restriction prevents forking intended to restrict public access or bypass the D-SAFE Specification requirements.
🚀 Getting Started for Junior Developers
In the world of Web3, contract addresses can change if the developers upgrade the system. Instead of hardcoding those addresses into your Vue.js or React application, you use this package to dynamically fetch the most up-to-date, official addresses directly from the blockchain!
Because querying the blockchain is slow, this package automatically intercepts those addresses and caches them instantly inside the user's Browser localStorage for 24 hours.
Installation
npm install @the_library/web3-registry-addresses(Note: Depending on which blockchains you want to support, you will also need the corresponding reader packages, like @the_library/web3-evm or @the_library/web3-tron).
1. Bootstrapping the Cache (Initialization)
When your application first loads, you need to "Boot" the D-CODE registry. This reads the official configuration loop and instructs this package to go out, fetch the addresses, and save them to the browser.
import { config, registryAddressLoader } from '@the_library/web3-registry-addresses';
import { EvmRegistryReadAPI } from '@the_library/web3-evm';
import { TronRegistryReadAPI } from '@the_library/web3-tron';
const loadDCODEContracts = async () => {
// Iterate over all endorsed technologies (EVM, Tron, etc.)
for (const tech of Object.keys(config)) {
// Iterate over all official network configurations for that tech
for (const network of Object.keys(config[tech as keyof typeof config])) {
const networkConfig = config[tech as keyof typeof config][network];
console.log(`Loading ${tech} network ${network}...`);
try {
// 1. Instantiate the active Read API based on the technology
const registryApi = tech === 'evm'
? new EvmRegistryReadAPI(networkConfig)
: new TronRegistryReadAPI(networkConfig);
// 2. Fetch and resolve the canonical smart contracts!
// This checks localStorage. If there is no cache, it asks the blockchain.
const addresses = await registryAddressLoader.Initialize(
tech as any,
network,
registryApi
);
console.log(`Resolved Contracts for ${tech}:${network}:`, addresses);
} catch (e) {
console.error(`Failed to load registry for ${network}`, e);
}
}
}
}2. Using the Cached Addresses Instantly
Once Initialize has finished anywhere in your app, you never have to await or fetch from the blockchain again for that session! You can instantly grab the certified address in any Vue component:
import { registryAddressLoader } from '@the_library/web3-registry-addresses';
// Example: Get the CORE Testnet address for the "Factory" contract
const getFactoryAddress = () => {
// This is synchronous and zero-latency! It reads directly from RAM/localStorage.
const address = registryAddressLoader.getAddress('evm', 1114, 'Factory');
if (!address) throw new Error("Registry Cache is not initialized!");
return address;
}By using this flow, your frontend is blazing fast, perfectly synced with the blockchain, and fully compliant with the D-SAFE architectural requirements!
COPYRIGHT: © 2026 DATAPOND PUBLIC LIBRARY TRUST - Australia TECHNICAL GUARDIAN: POND ENTERPRISE PTY LTD - Australia
