[][src]Function casperlabs_contract::ext_ffi::transfer_to_account

pub unsafe extern "C" fn transfer_to_account(
    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 current account’s main 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 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 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 current account’s main purse had insufficient tokens or because the function was called outside of session code and so does not have access to the account’s main purse).

Arguments

  • target_ptr - pointer in wasm memory to bytes representing the target account to transfer to
  • target_size - size of the target (in bytes)
  • amount_ptr - pointer in wasm memory to bytes representing the amount to transfer to the target account
  • amount_size - size of the amount (in bytes)