pub fn calldata() -> Result<Vec<u8>>Expand description
Returns the raw calldata (function selector + arguments).
Calldata format:
- Bytes 0-3: Function selector (4 bytes)
- Bytes 4+: Encoded arguments
§Returns
A Vec<u8> containing the complete calldata.
§Example
ⓘ
let calldata = context::calldata()?;
let selector = abi::selector(&calldata)?;
if selector == abi::selector_of("transfer") {
let to = abi::read_account(&calldata, 4)?;
let amount = abi::read_u64(&calldata, 36)?;
// Handle transfer...
}