const rpc = e.target.elements['rpc'].value;
const output = e.target.elements['output'];
+ const payload = [];
const slots = {
'Logic contract address': '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc',
'Beacon contract address': '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50',
'Admin address': '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'
}
- const payload = [];
for (const [key, value] of Object.entries(slots)) {
payload.push({
jsonrpc: '2.0',
params: [contract, value, 'latest']
});
}
+ const events = {
+ 'Upgraded': '0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b',
+ 'Beacon upgraded': '0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e',
+ 'Admin changed': '0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f'
+ }
+ for (const [key, value] of Object.entries(events)) {
+ payload.push({
+ jsonrpc: '2.0',
+ id: key,
+ method: 'eth_getLogs',
+ params: [{
+ fromBlock: 'earliest',
+ toBlock: 'latest',
+ address: contract,
+ topics: [value]
+ }]
+ });
+ }
const results = await fetch(rpc, {
method: 'POST',
output.innerHTML = '';
for (const item of results) {
- output.insertAdjacentHTML('beforeend', `<p>${item.id}: 0x${item.result.substring(26)}</p>`);
+ if (typeof item.result === 'string') { // Storage slot lookup
+ output.insertAdjacentHTML('beforeend', `<p>${item.id}: 0x${item.result.substring(26)}</p>`);
+ }
+ else { // Event lookup
+ for (const log of item.result) {
+ if (log.data === '0x') { // Upgraded event (new address is indexed)
+ output.insertAdjacentHTML('beforeend', `<p>${item.id} (block ${Number(log.blockNumber)}): 0x${log.topics[1].substring(26)}</p>`);
+ }
+ else { // Admin changed event (new address is not indexed)
+ output.insertAdjacentHTML('beforeend', `<p>${item.id} (block ${Number(log.blockNumber)}): 0x${log.data.slice(-40)}</p>`);
+ }
+ }
+ }
}
});
</script>