[][src]Function casperlabs_contract::ext_ffi::add_associated_key

pub unsafe extern "C" fn add_associated_key(
    account_hash_ptr: *const u8,
    account_hash_size: usize,
    weight: i32
) -> i32

This function attempts to add the given public key as an associated key to the current account. Presently only 32-byte keys are supported; it is up to the caller to ensure that the 32-bytes starting from offset public_key represent the key they wish to add. Weights are internally represented by a u8, this function will cause a Trap if the weight is not between 0 and 255 inclusively. The result returned is a status code for adding the key where 0 represents success, 1 means no more keys can be added to this account (only 10 keys can be added), 2 means the key is already associated (if you wish to change the weight of an associated key then used update_associated_key), and 3 means permission denied (this could be because the function was called outside of session code or because the key management threshold was not met by the keys authorizing the deploy).

Returns status code for adding the key, where 0 represents success and non-zero represents failure.

Arguments

  • public_key - pointer to the bytes in wasm memory representing the public key to add, presently only 32-byte public keys are supported.
  • weight - the weight to assign to this public key