All Products
Search
Document Center

Blockchain as a Service:Account Interface

Last Updated:Mar 31, 2026

The JavaScript (JS) SDK account interface provides six operations for managing blockchain accounts: creating accounts, transferring balances, and managing cryptographic keys.

Key concepts

Name-based accounts — Accounts on this blockchain are identified by name strings (such as 'Tester001'), not by cryptographic addresses. The from and to parameters in each operation are account names.

Two-key model — Each account holds two distinct keys:

  • Auth key (auth_key): The key used to authorize transactions. Use ResetPubKey to replace it.

  • Recovery key (recover_key): A backup key for account recovery. Use SetRecoverkey to update it.

Weight — The current JS SDK supports only one auth key per account. Set auth_weight to 100. If multiple auth keys are supported in a future release, the weights of all auth keys must sum to 100.

Warning

Never share or store private keys in plaintext. Store key material in environment variables or a secrets manager.

Create accounts

Call CreateAccount to create a new account on the blockchain.

Parameters

All parameters are passed as a single object.

ParameterRequiredTypeDescription
fromYesstringThe account name used to create the new account.
toYesstringThe name of the new account.
dataYesobjectKey material for the new account. See the data fields below.

`data` fields:

FieldRequiredTypeDescription
recover_keyNostringA 0x-prefixed hex string, 64 bytes excluding the 0x prefix.
auth_keyNostringA 0x-prefixed hex string, 64 bytes excluding the 0x prefix.
auth_weightNostringWeight of the auth key. Set to 100.

Examples

Use an existing public key

chain.ctr.CreateAccount({
  from: 'Tester001',
  to: 'Tester002',
  data: {
    recover_key: '0xf5e50510a04a3f659a0e89f2063f79f8c1aed5ddaab6420ac47700020d9889dc14dae4dc9843c88d8222167095d9e6ce052e8a19cbc737c3f3cddf66409dbb0a',
    auth_key: '0xf5e50510a04a3f659a0e89f2063f79f8c1aed5ddaab6420ac47700020d9889dc14dae4dc9843c88d8222167095d9e6ce052e8a19cbc737c3f3cddf66409dbb0a',
    auth_weight: 100
  }
}, (err, data) => {
  console.log(data)
})

Generate a new EC key pair

Use Chain.utils.generateECKey() to create a new key pair and use its public key for both recover_key and auth_key.

const newKey = Chain.utils.generateECKey();
console.log('Private key:', newKey.privateKey.toString('hex'))
console.log('Public key:', newKey.publicKey.toString('hex'))

chain.ctr.CreateAccount({
  from: 'Tester001',
  to: 'Tester003',
  data: {
    recover_key: '0x' + newKey.publicKey.toString('hex'),
    auth_key: '0x' + newKey.publicKey.toString('hex'),
    auth_weight: 100
  }
}, (err, data) => {
  console.log(data)
})

Transfer balances

Call TransferBalance to transfer funds from one account to another.

Parameters

All parameters are passed as a single object.

ParameterRequiredTypeDescription
fromYesstringThe source account name.
toYesstringThe destination account name.
valueYesnumberThe limit of the transfer amount.

Example

chain.ctr.TransferBalance({
  from: 'Tester001',
  to: 'Tester002',
  value: 0
}, (err, data) => {
  console.log(data)
})

Set the recovery key

Call SetRecoverkey to set or update the recovery key for an account.

Parameters

All parameters are passed as a single object.

ParameterRequiredTypeDescription
fromYesstringThe account to update.
dataYesobjectRecovery key data. See the data fields below.

`data` fields:

FieldRequiredTypeDescription
recover_keyYesstringA 0x-prefixed hex string, 64 bytes excluding the 0x prefix.

Example

chain.ctr.SetRecoverkey({
  from: account,
  data: {
    recover_key: publicKey
  }
}, (err, data) => {
  console.log(data)
})

Pre-reset the public key

Call PreResetPubKey to initiate a public key reset for an account.

Parameters

All parameters are passed as a single object.

ParameterRequiredTypeDescription
fromYesstringThe account whose public key will be reset.

Example

chain.ctr.PreResetPubKey({
  from: 'Tester001'
}, (err, data) => {
  console.log(data)
})

Reset the public key

Call ResetPubKey to replace the auth key for an account.

Parameters

All parameters are passed as a single object.

ParameterRequiredTypeDescription
fromYesstringThe account whose auth key will be replaced.
dataYesobjectThe new auth key data. See the data fields below.

`data` fields:

FieldRequiredTypeDescription
auth_keyYesstringA 0x-prefixed hex string, 64 bytes excluding the 0x prefix.
auth_weightYesnumberWeight of the auth key. Set to 100. If multiple auth keys are supported in a future release, the sum of all weights must equal 100.

Example

chain.ctr.ResetPubKey({
  from: 'Tester001',
  data: {
    auth_key: '0xf5e50510a04a3f659a0e89f2063f79f8c1aed5ddaab6420ac47700020d9889dc14dae4dc9843c88d8222167095d9e6ce052e8a19cbc737c3f3cddf66409dbb0a',
    auth_weight: 100,
  }
}, (err, data) => {
  console.log(data)
})

Update key weights

Call UpdateAuthMap to update the weight of a public key for an account.

Parameters

All parameters are passed as a single object.

ParameterRequiredTypeDescription
fromYesstringThe account to update.
dataYesobjectThe updated auth key data. See the data fields below.

`data` fields:

FieldRequiredTypeDescription
auth_keyYesstringA 0x-prefixed hex string, 64 bytes excluding the 0x prefix.
auth_weightYesnumberWeight of the auth key. Set to 100. If multiple auth keys are supported in a future release, the sum of all weights must equal 100.

Example

chain.ctr.UpdateAuthMap({
  from: 'Tester001',
  data: {
    auth_key: '0xf5e50510a04a3f659a0e89f2063f79f8c1aed5ddaab6420ac47700020d9889dc14dae4dc9843c88d8222167095d9e6ce052e8a19cbc737c3f3cddf66409dbb0a',
    auth_weight: 100,
  }
}, (err, data) => {
  console.log(data)
})