Skip to main content

set_return_data

Function set_return_data 

Source
pub fn set_return_data(data: &[u8]) -> Result<()>
Expand description

Sets the return data for this contract call.

The return data is sent back to the caller and can be decoded by the client. Typically used to return function results (balances, status codes, etc.).

§Arguments

  • data - The bytes to return to the caller

§Example

// Return a u64 balance
let balance = 1000u64;
context::set_return_data(&balance.to_le_bytes())?;

// Return multiple values (encode them first)
let mut encoder = Encoder::new();
encoder.push_u64(balance);
encoder.push_bool(is_active);
context::set_return_data(encoder.as_slice())?;