Amount of Asset Sent

The standard library provides a function msg_amount() which retrieves the amount of asset sent without any concern for which asset is sent.

This can be used to set a price or manually track the amount sent by each user.

Example

To use msg_amount() we must import it from the standard library.

use std::context::msg_amount;

We can check how much of any asset has been sent and if an incorrect amount has been sent then we may revert.

fn purchase() {
    require(msg_amount() == 100_000_000, "Incorrect amount sent");
    // code
}