{"id":34727538,"url":"https://github.com/powei-lin/web3-constant","last_synced_at":"2026-05-23T08:34:01.620Z","repository":{"id":57673291,"uuid":"481375754","full_name":"powei-lin/web3-constant","owner":"powei-lin","description":"Useful constants for web3py","archived":false,"fork":false,"pushed_at":"2022-05-02T20:51:12.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-08T18:04:08.583Z","etag":null,"topics":["cryptocurrency","web3","web3py"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/powei-lin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-13T21:13:40.000Z","updated_at":"2024-04-27T03:57:33.000Z","dependencies_parsed_at":"2022-08-31T08:22:14.915Z","dependency_job_id":null,"html_url":"https://github.com/powei-lin/web3-constant","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/powei-lin/web3-constant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powei-lin%2Fweb3-constant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powei-lin%2Fweb3-constant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powei-lin%2Fweb3-constant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powei-lin%2Fweb3-constant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/powei-lin","download_url":"https://codeload.github.com/powei-lin/web3-constant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powei-lin%2Fweb3-constant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33389224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptocurrency","web3","web3py"],"created_at":"2025-12-25T02:32:11.258Z","updated_at":"2026-05-23T08:34:01.614Z","avatar_url":"https://github.com/powei-lin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web3-constant\n\n### Install\n```\npip install web3-abi web3-constant\n```\n\n### Connect to Web3\n``` py3\nfrom web3 import Web3\nfrom web3constant.Fantom.Url import FTM_RPC\n\nw3 = Web3(Web3.HTTPProvider(FTM_RPC))\nif w3.isConnected():\n    print(\"Web3 is connected.\")\n```\n\n### Listen to a topic\n``` py3\nfrom web3 import Web3\nfrom web3constant.Fantom.Url import FTM_RPC\nfrom web3constant.topics import PAIR_SYNC\n\nw3 = Web3(Web3.HTTPProvider(FTM_RPC))\n\nprev_block_num = w3.eth.get_block_number()\nwhile(True):\n    current_block = w3.eth.get_block_number()\n    if (prev_block_num == current_block):\n        continue\n\n    topic_d = {\n        'fromBlock': prev_block_num,\n        'topics': [PAIR_SYNC]\n    }\n    logs = w3.eth.get_logs(topic_d)\n    for l in logs:\n      print(l)\n```\n\n\n### Create contract\n``` py3\nfrom web3 import Web3\nfrom web3constant.Fantom.Url import FTM_RPC\nfrom web3constant.Fantom.Dex import SPOOKY_SWAP_FACTORY_ADDRESS\nfrom web3abi.UniswapV2 import SPOOKY_SWAP_FACTORY_ABI, UNISWAP_V2_PAIR_ABI\n\nw3 = Web3(Web3.HTTPProvider(FTM_RPC))\n\n# create factory contract\nspooky_swap_factory_contract = w3.eth.contract(\n    address=SPOOKY_SWAP_FACTORY_ADDRESS, abi=SPOOKY_SWAP_FACTORY_ABI\n)\n\n# get pair address for factory contract\npair_address = spooky_swap_factory_contract.functions.allPairs(0).call()\nprint(\"pair contract address:\", pair_address)\n\n# create pair contract\npair_contract = w3.eth.contract(address=pair_address, abi=UNISWAP_V2_PAIR_ABI)\n\n# get token0, token1\ntoken0 = pair_contract.functions.token0().call()\ntoken1 = pair_contract.functions.token1().call()\n\n# get reserves\nr0, r1, timestamp = pair_contract.functions.getReserves().call()\n\n# print\nprint(\"token0:\", token0)\nprint(\"token0 reserves:\", r0)\nprint(\"token1:\", token1)\nprint(\"token1 reserves:\", r1)\nprint(\"sync timestamp:\", timestamp)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowei-lin%2Fweb3-constant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowei-lin%2Fweb3-constant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowei-lin%2Fweb3-constant/lists"}