[−][src]Function casperlabs_contract::ext_ffi::transfer_from_purse_to_account
pub unsafe extern "C" fn transfer_from_purse_to_account(
source_ptr: *const u8,
source_size: usize,
target_ptr: *const u8,
target_size: usize,
amount_ptr: *const u8,
amount_size: usize
) -> i32
This function uses the mint contract’s transfer function to transfer
tokens from the specified purse to the main purse of the target account.
If the target account does not exist then it is automatically created, and
the tokens are transferred to the main purse of the new account. The
source is a serialized casperlabs_types::uref::URef
.
The target is a serialized PublicKey
(i.e. 36 bytes where the
first 4 bytes are the number 32
in little endian encoding, and the
remaining 32-bytes are the public key). The amount must be a serialized
512-bit unsigned integer. This function causes a Trap
if the source
cannot be de-serialized as a casperlabs_types::uref::URef
, or the target cannot be
de-serialized as a PublicKey
or the amount cannot be de-serialized into
a U512
. The return value indicated what occurred, where 0 means a
successful transfer to an existing account, 1 means a successful transfer
to a new account, and 2 means the transfer failed (this could be because
the source purse had insufficient tokens or because there was not valid
access to the source purse).
Arguments
source_ptr
- pointer in wasm memory to bytes representing the sourcecasperlabs_types::uref::URef
to transfer fromsource_size
- size of the sourcecasperlabs_types::uref::URef
(in bytes)target_ptr
- pointer in wasm memory to bytes representing the target account to transfer totarget_size
- size of the target (in bytes)amount_ptr
- pointer in wasm memory to bytes representing the amount to transfer to the target accountamount_size
- size of the amount (in bytes)