The ABI is static and won’t change. Fetch it once during initialization and cache it.
// Bad: Fetching every timeasync function getValidators() { const abi = JSON.parse(await web3.getSystemContractABI()); const contract = new web3.eth.Contract(abi, address); return await contract.methods.getActiveValidators().call();}// Good: Cache and reuseconst ABI_CACHE = JSON.parse(await web3.getSystemContractABI());const systemContract = new web3.eth.Contract(ABI_CACHE, address);async function getValidators() { return await systemContract.methods.getActiveValidators().call();}
Version in Production
In production, consider hardcoding the ABI or loading from a file to avoid RPC calls.
This ABI includes all functions: user functions (stake, claim), view functions (getValidatorInfo), and admin functions. Your wallet will only be able to call functions you have permission for.