get_function_selector

Documentation for eth_defi.abi.get_function_selector function.

get_function_selector(func)[source]

Get Solidity function selector.

Does not support multiple Solidity functions with the same name, but different arguments. On multiple functions use one first declared in ABI.

Example:

selector = get_function_selector(uniswap_v2.router.functions.swapExactTokensForTokens)
assert selector.hex() == 38ed1739
Parameters

func (web3.contract.contract.ContractFunction) – Unbound or bound contract function proxy

Returns

Solidity function selector.

First 32-bit (4 bytes) keccak hash.

Return type

bytes