Chainlog historical API
Usage
Get a list of all available chains and versions
GET https://chainlog.skyeco.com/api/index.json
Get the active version on a given chain
GET https://chainlog.skyeco.com/api/{chain}/active.json
Get a specific version on a given chain
GET https://chainlog.skyeco.com/api/{chain}/{version}.json
Code examples
You can set your JavaScript app to use this API in the following way:
const url = "https://chainlog.skyeco.com/api/mainnet/active.json";
const response = await fetch(url);
const chainlog = await response.json();
console.log(chainlog);
If you care about decentralization, however, do not use this API. Instead query the blockchain directly:
const address = "0xda0ab1e0017debcd72be8599041a2aa3ba7e740f";
const abi = [
"function list() external view returns (bytes32[])",
"function getAddress(bytes32) external view returns (address)"
];
const provider = ethers.getDefaultProvider();
const chainlog = new ethers.Contract(address, abi, provider);
const list = await chainlog.list();
const result = {};
for (let keyHex of list) {
const key = ethers.utils.parseBytes32String(keyHex);
const address = await chainlog.getAddress(keyHex);
result[key] = address;
}
console.log(result);
Please note that the above code will only retreive the latest data.
You can also ditch web3 libraries and perform low-level JSON RPC calls. Here is an example with Python:
keys = requests.post("https://chain.techops.services/eth-mainnet", json={
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F",
"data": "0x0f560cd7"
}, "latest"],
"id": 0
}).json()["result"][130:]
result = {}
for i in range(0, len(keys), 64):
address = "0x" + requests.post("https://chain.techops.services/eth-mainnet", json={
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F",
"data": "0x21f8a721" + keys[i:i+64]
}, "latest"],
"id": 0
}).json()["result"][26:]
key = bytes.fromhex(keys[i:i+64]).replace(b"\x00", b"").decode("ascii")
result[key] = address
print(result)
The above code has the advantage that it will allow you to retreive historical data as long as you are using an archival node. In order to do that, replace "latest" with a specific block number.
Available resources in this API
https://chainlog.skyeco.com/api
├── index.json