pub trait FungibleTokenReceiver {
// Required method
fn ft_on_transfer(
&mut self,
sender_id: AccountId,
amount: U128,
msg: String,
) -> PromiseOrValue<U128>;
}
Required Methods§
Sourcefn ft_on_transfer(
&mut self,
sender_id: AccountId,
amount: U128,
msg: String,
) -> PromiseOrValue<U128>
fn ft_on_transfer( &mut self, sender_id: AccountId, amount: U128, msg: String, ) -> PromiseOrValue<U128>
Called by fungible token contract after ft_transfer_call
was initiated by
sender_id
of the given amount
with the transfer message given in msg
field.
The amount
of tokens were already transferred to this contract account and ready to be used.
The method must return the amount of tokens that are not used/accepted by this contract from the transferred amount. Examples:
- The transferred amount was
500
, the contract completely takes it and must return0
. - The transferred amount was
500
, but this transfer call only needs450
for the action passed in themsg
field, then the method must return50
. - The transferred amount was
500
, but the action inmsg
field has expired and the transfer must be cancelled. The method must return500
or panic.
Arguments:
sender_id
- the account ID that initiated the transfer.amount
- the amount of tokens that were transferred to this account in a decimal string representation.msg
- a string message that was passed with this transfer call.
Returns the amount of unused tokens that should be returned to sender, in a decimal string representation.