[][src]Function transaction_builder::encode_create_child_vasp_account_script

pub fn encode_create_child_vasp_account_script(
    coin_type: TypeTag,
    child_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    add_all_currencies: bool,
    child_initial_balance: u64
) -> Script

Summary

Creates a Child VASP account with its parent being the sending account of the transaction. The sender of the transaction must be a Parent VASP account.

Technical Description

Creates a ChildVASP account for the sender parent_vasp at child_address with a balance of child_initial_balance in CoinType and an initial authentication key of auth_key_prefix | child_address.

If add_all_currencies is true, the child address will have a zero balance in all available currencies in the system.

The new account will be a child account of the transaction sender, which must be a Parent VASP account. The child account will be recorded against the limit of child accounts of the creating Parent VASP account.

Events

Successful execution with a child_initial_balance greater than zero will emit:

Parameters

NameTypeDescription
CoinTypeTypeThe Move type for the CoinType that the child account should be created with. CoinType must be an already-registered currency on-chain.
parent_vasp&signerThe signer reference of the sending account. Must be a Parent VASP account.
child_addressaddressAddress of the to-be-created Child VASP account.
auth_key_prefixvector<u8>The authentication key prefix that will be used initially for the newly created account.
add_all_currenciesboolWhether to publish balance resources for all known currencies when the account is created.
child_initial_balanceu64The initial balance in CoinType to give the child account when it's created.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::INVALID_ARGUMENTLibraAccount::EMALFORMED_AUTHENTICATION_KEYThe auth_key_prefix was not of length 32.
Errors::REQUIRES_ROLERoles::EPARENT_VASPThe sending account wasn't a Parent VASP account.
Errors::ALREADY_PUBLISHEDRoles::EROLE_IDThe child_address address is already taken.
Errors::LIMIT_EXCEEDEDVASP::ETOO_MANY_CHILDRENThe sending account has reached the maximum number of allowed child accounts.
Errors::NOT_PUBLISHEDLibra::ECURRENCY_INFOThe CoinType is not a registered currency on-chain.
Errors::INVALID_STATELibraAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTEDThe withdrawal capability for the sending account has already been extracted.
Errors::NOT_PUBLISHEDLibraAccount::EPAYER_DOESNT_HOLD_CURRENCYThe sending account doesn't have a balance in CoinType.
Errors::LIMIT_EXCEEDEDLibraAccount::EINSUFFICIENT_BALANCEThe sending account doesn't have at least child_initial_balance of CoinType balance.
Errors::INVALID_ARGUMENTLibraAccount::ECANNOT_CREATE_AT_VM_RESERVEDThe child_address is the reserved address 0x0.

Related Scripts