pub fn encode_create_child_vasp_account_script_function(
    coin_type: TypeTag,
    child_address: AccountAddress,
    auth_key_prefix: Vec<u8, Global>,
    add_all_currencies: bool,
    child_initial_balance: u64
) -> TransactionPayloadExpand description
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. Authentication key prefixes, and how to construct them from an ed25519 public key is described
here.
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 will emit:
- A DiemAccount::CreateAccountEventwith thecreatedfield beingchild_address, and therold_idfield beingRoles::CHILD_VASP_ROLE_ID. This is emitted on theDiemAccount::AccountOperationsCapabilitycreation_eventshandle.
Successful execution with a child_initial_balance greater than zero will additionaly emit:
- A DiemAccount::SentPaymentEventwith thepayeefield beingchild_address. This is emitted on the Parent VASP’sDiemAccount::DiemAccountsent_eventshandle.
- A DiemAccount::ReceivedPaymentEventwith thepayerfield being the Parent VASP’s address. This is emitted on the new Child VASPS’sDiemAccount::DiemAccountreceived_eventshandle.
Parameters
| Name | Type | Description | 
|---|---|---|
| CoinType | Type | The Move type for the CoinTypethat the child account should be created with.CoinTypemust be an already-registered currency on-chain. | 
| parent_vasp | signer | The reference of the sending account. Must be a Parent VASP account. | 
| child_address | address | Address of the to-be-created Child VASP account. | 
| auth_key_prefix | vector<u8> | The authentication key prefix that will be used initially for the newly created account. | 
| add_all_currencies | bool | Whether to publish balance resources for all known currencies when the account is created. | 
| child_initial_balance | u64 | The initial balance in CoinTypeto give the child account when it’s created. | 
Common Abort Conditions
| Error Category | Error Reason | Description | 
|---|---|---|
| Errors::INVALID_ARGUMENT | DiemAccount::EMALFORMED_AUTHENTICATION_KEY | The auth_key_prefixwas not of length 32. | 
| Errors::REQUIRES_ROLE | Roles::EPARENT_VASP | The sending account wasn’t a Parent VASP account. | 
| Errors::ALREADY_PUBLISHED | Roles::EROLE_ID | The child_addressaddress is already taken. | 
| Errors::LIMIT_EXCEEDED | VASP::ETOO_MANY_CHILDREN | The sending account has reached the maximum number of allowed child accounts. | 
| Errors::NOT_PUBLISHED | Diem::ECURRENCY_INFO | The CoinTypeis not a registered currency on-chain. | 
| Errors::INVALID_STATE | DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED | The withdrawal capability for the sending account has already been extracted. | 
| Errors::NOT_PUBLISHED | DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY | The sending account doesn’t have a balance in CoinType. | 
| Errors::LIMIT_EXCEEDED | DiemAccount::EINSUFFICIENT_BALANCE | The sending account doesn’t have at least child_initial_balanceofCoinTypebalance. | 
| Errors::INVALID_ARGUMENT | DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED | The child_addressis the reserved address 0x0. | 
Related Scripts
- AccountCreationScripts::create_parent_vasp_account
- AccountAdministrationScripts::add_currency_to_account
- AccountAdministrationScripts::rotate_authentication_key
- AccountAdministrationScripts::add_recovery_rotation_capability
- AccountAdministrationScripts::create_recovery_address