Skip to content

Commit d42332b

Browse files
committed
main function
to run the mapper from the commandline (optional)
1 parent 5f55b90 commit d42332b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/solidity_address_mapper/mapper.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,28 @@ def _read_from_json_file(file_path, item_path: str):
452452
return next(objects)
453453
except StopIteration:
454454
raise KeyError(f"Path '{item_path}' not found in JSON file '{file_path}'")
455+
456+
if __name__ == "__main__":
457+
import argparse
458+
459+
parser = argparse.ArgumentParser(
460+
description="Map a hex address in EVM bytecode to Solidity source code location."
461+
)
462+
parser.add_argument(
463+
"--compiler_output_json", "-j", required=True, help="Path to the Solidity compiler output JSON file."
464+
)
465+
parser.add_argument(
466+
"--address_hex", "-a", required=True, help="Hexadecimal address (e.g., 0x1525 or 1525)."
467+
)
468+
parser.add_argument(
469+
"--contract_name", "-c", required=True, help="Name of the contract."
470+
)
471+
472+
args = parser.parse_args()
473+
474+
result = Mapper.map_hex_address(
475+
compiler_output_json=args.compiler_output_json,
476+
address_hex=args.address_hex,
477+
contract_name=args.contract_name,
478+
)
479+
print(result)

0 commit comments

Comments
 (0)