Skip to main content

📝 Reading Beacon via Static Call

You can also read data from Beacons from an off-chain application. Below snippets shows this in TypeScript and Python.

Check Beacon addresses and contract addresses to try it out. Also you can find RPC URLs at ChainList.

const RPC_URL = "https://matic-mumbai.chainstacklabs.com";
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const DapiServerAddress = "0x71Da7A936f...";
const beaconId = "0xe6bc56045455c...";
const DapiServerAbi = '...';

const dapiServer = new ethers.Contract(DapiServerAddress, DapiServerAbi, provider);
dapiServer.readDataFeedWithId(beaconId).then((ret: any) => {
console.log(ret);
});

/*
Example output:
[
BigNumber { _hex: '0x0de0c919d15abc00', _isBigNumber: true },
1664290764,
value: BigNumber { _hex: '0x0de0c919d15abc00', _isBigNumber: true },
timestamp: 1664290764
]
*/