CallNode.caller_functions()
Returns Functions object for the functions that call the current node corresponding function.
caller_functions() โ Functions
Query Example
from glider import *
# task: find a function that has `burn*` call and return all the functions that has a call to that function
def query():
data = []
instructions = Instructions().with_callee_name_prefix('burn').exec(10)
for instruction in instructions:
if len(data) > 0:
break # demo first result only
functionContainsBurn = instruction.get_parent() #api.functions.Function (*)
contract = functionContainsBurn.get_contract() #api.contracts.Contract
call_graph = contract.call_graph() #api.call_graph.CallGraph
nodes = call_graph.nodes() #Dict[str, CallNode]
for id in nodes:
if(id != functionContainsBurn.db_id):
continue
caller_functions = nodes[id].caller_functions #api.functions.Functions
callers = caller_functions().exec() #List[Function]
if len(callers) > 0:
print(functionContainsBurn.source_code())
for caller in callers:
print(caller.source_code())
data.append(instruction)
return dataExample Output
Output below represents printed output from the caller's source code:
Last updated