Skip to main content

Step 4: Sending assets to non-existent accounts

Exchanges can send assets to users who do not yet have a Chromia account by transferring funds to an unregistered account. This process allows users to activate their accounts through the Chromia Vault. The exchange should first verify if the user has an existing Chromia account:

  1. If the account exists: You can send any amount of CHR.
  2. If the account does not exist: Notify the user that they need to send at least 10 CHR, as this is the required fee for account creation.

Once the transfer is complete, users can visit the Chromia Vault to activate their accounts. Below is the implementation example:

// Create a single-signature account descriptor for the new account
const authDescriptor = createSingleSigAuthDescriptorRegistration(
["A", "T"], // Fixed value for the economy chain
Buffer.from("pubkey or EVM address, without 0x", "hex"), // Public key or EVM-compatible address of the recipient
null // No additional rules; this is standard for all account registrations
);

// Retrieve the account ID for the single-signature account
const signer = authDescriptor.args.signer;
const singleSigAccId = gtv.gtvHash(signer);

// Transfer assets to the unregistered account
// Ensure the amount is at least 10 CHR to cover the account creation fee
myAccount.transfer(
singleSigAccId,
"CHR asset id as hex", // The unique identifier for the CHR asset
createAmount(19, 6) // Amount: 19 CHR (9 will be available; 10 will be used as the account creation fee)
);

// The user needs to visit the Chromia Vault to activate their account
// Inform the user to go to https://vault.chromia.com for account activation

// Creating the account yourself
// Set up an in-memory key store with the private key for signing
const ks = createInMemoryFtKeyStore(encryption.makeKeyPair("privkey"));

// Register the account using the provided registration strategy
const { session } = await registerAccount(client, ks, registrationStrategy.transferFee(CHRAsset, authDescriptor, null));
// After registration, the session can be used for further operations. The account is now created and can be retrieved as described in the previous steps.