pub fn encode_function_call(
functions: &BTreeMap<String, Vec<Function>>,
call_text: &str,
) -> Result<Bytes>Expand description
Encode a text-form function call to bytes using the provided function ABI
§Arguments
functions- BTreeMap of function name to list of function definitionscall_text- Text representation of function call (e.g., “balanceOf(0x123424)”)
§Returns
Result<Bytes>- Encoded function call data on success
§Examples
use std::collections::BTreeMap;
use alloy_json_abi::Function;
let mut functions = BTreeMap::new();
// functions.insert("balanceOf".to_string(), vec![balance_of_function]);
// Basic function call
let encoded = encode_function_call(&functions, "balanceOf(0x742d35Cc6634C0532925a3b8D6Ac6E89e86C6Ad1)")?;
// Function call with struct syntax (for tuples/structs)
let encoded = encode_function_call(&functions, "submitData({user: 0x123..., amount: 100})")?;
// Function call with traditional tuple syntax
let encoded = encode_function_call(&functions, "submitData((0x123..., 100))")?;
// Complex nested structures
let encoded = encode_function_call(&functions, "complexCall({data: {nested: [1,2,3]}, value: 456})")?;