Skip to content

Commit

Permalink
feat: get contracts from sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
eugypalu committed Sep 13, 2024
1 parent 2e0f299 commit ce6aa44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
WEB3_HTTP_PROVIDER_URI="http://0.0.0.0:3030"

HYPOTHESIS_PROFILE=dev

VOYAGER_API_KEY=
25 changes: 23 additions & 2 deletions kakarot_scripts/withdraw_accounts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# %% Imports
import logging
import os
from asyncio import run

import requests

from kakarot_scripts.constants import ETH_TOKEN_ADDRESS, NETWORK, RPC_CLIENT
from kakarot_scripts.utils.starknet import get_balance, get_declarations, invoke

Expand All @@ -10,12 +13,30 @@
logger.setLevel(logging.INFO)


# %% Fetch contract events
def get_contracts():
url = f"https://sepolia-api.voyager.online/beta/events?ps=10&p=1&contract={os.getenv('KAKAROT_SEPOLIA_ACCOUNT_ADDRESS')}"
headers = {
"accept": "application/json",
"x-api-key": os.getenv("VOYAGER_API_KEY"),
}
response = requests.get(url, headers=headers)
return [
{
"evm_address": "0x" + raw[2:22].hex(),
"starknet_address": "0x" + raw[23:].hex(),
}
for raw in (
bytes(contract["data"]["data"]) for contract in response.json()["items"]
)
]


# %% Main
async def main():
# %% Withdraw all accounts

# TODO: List of {evm_address, starknet_address} dict to be retrieved from parsing Kakarot contract events
contracts = []
contracts = get_contracts()

balance_prev = await get_balance(NETWORK["account_address"])
logger.info(f"ℹ️ Current deployer balance {balance_prev / 1e18} ETH")
Expand Down

0 comments on commit ce6aa44

Please sign in to comment.