Callable.get_contract()

Returns the parent contract of the function/modifier if exists, otherwise (global functions) returns NoneObject.

get_contract() β†’ Contract | NoneObject

The function may return NoneObject in cases where it does not belong to any contract and is a global function, as Solidity supports that type of functions.

Example

from glider import *
def query():
  functions = Functions().without_modifier_names(["onlyOwner"]).exec(100)

  contracts = []
  for function in functions:
    # For each function without an "onlyOwner" modifier, return the contract
    contracts.append(function.get_contract())

  return contracts

Example output

[
  {
    "contract": "0x798AcB51D8FBc97328835eE2027047a8B54533AD",
    "contract_name": "IERC721"
  },
  {
    "contract": "0x798AcB51D8FBc97328835eE2027047a8B54533AD",
    "contract_name": "IERC721Metadata"
  },
  ...
]

Last updated