Skip to main content

call_value

Function call_value 

Source
pub fn call_value() -> Result<u128>
Expand description

Returns the amount of native tokens sent with this call.

Only non-zero when called via call_contract_with_value(). The value is transferred before contract execution begins.

§Returns

The amount of native tokens (in base units) sent with the call.

§Example

let value = context::call_value()?;
 
if value < MINIMUM_DEPOSIT {
    return Err(Error::new(ERR_INSUFFICIENT_VALUE));
}
 
// Credit the caller's balance
balances.insert(&caller, &value)?;