Function casper_contract::ext_ffi::casper_transfer_from_purse_to_account[][src]

pub unsafe extern "C" fn casper_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,
    id_ptr: *const u8,
    id_size: usize,
    result_ptr: *const i32
) -> i32
Expand description

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 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 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 source URef to transfer from
  • source_size - size of the source URef (in bytes)
  • 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)
  • id_ptr - pointer in wasm memory to bytes representing the user-defined transaction id
  • id_size - size of the id (in bytes)
  • result_ptr - pointer in wasm memory to a value where TransferredTo value would be set on successful transfer.