Live addresses

Constant

World

0x89090F774BeC95420f6359003149f51fec207133

Dynamic

Component and system addresses can change when upgrading/deploying. These addresses are instead stored in World, and reference via its id.

const getCompAddr = async (strID: string): Promise<string> => {
  const world = new ethers.Contract(worldAddr, WorldABI, provider);
  const systemRegistry = await world.components();

  const id = ethers.utils.solidityKeccak256(['string'], [strID]);
  return await getAddrByID(systemRegistry, id);
};

const getSystemAddr = async (strID: string): Promise<string> => {
  const world = new ethers.Contract(worldAddr, WorldABI, provider);
  const systemRegistry = await world.systems();

  const id = ethers.utils.solidityKeccak256(['string'], [strID]);
  return await getAddrByID(systemRegistry, id);
};

const getAddrByID = async (
  compsAddr: string,
  id: BigNumberish
): Promise<string> => {
  const comp = new ethers.Contract(compsAddr, UintCompABI, provider);
  const values = await comp.getEntitiesWithValue(id);
  return values.length > 0 ? values[0].toHexString() : '0x0000000000000000000000000000000000000000';
};

Last updated