An account is a data entry that's stored in the chain ledger, on-chain accounts are controlled by off-chain wallets, see understanding accounts and wallets.
There are several ways to create an account in the ledger.
Create accounts with DeclareTx
The most intuitive way to create an account is to send a DeclareTx to the chain, here are a few examples:
With account moniker
const { fromRandom } = require("@ocap/wallet");
const Client = require("@ocap/client");
const client = new Client("https://beta.abtnetwork.io/api/");
const wallet = fromRandom();
const hash = await client.declare({ moniker: "chain-user", wallet });The moniker field will be displayed on the account detail page in chain explorer like this:

With customized type
Each account can customize the role type, key-type and hash-type for its address:
const { types } = require("@ocap/mcrypto");
const { fromRandom } = require("@ocap/wallet");
const Client = require("@ocap/client");
const client = new Client("https://beta.abtnetwork.io/api/");
const wallet = fromRandom({
role: types.RoleType.ROLE_BOT, // default to ROLE_ACCOUNT
key: types.KeyType.ED25519, // default to ED25519
hash: types.HashType.SHA3, // default to SHA3
});
const hash = await client.declare({ moniker: "customized-did", wallet });With account issuer
You can also set the issuer field when creating an account, with this field you can relate multiple accounts in a public way:
issuermust be a valid account addressissuermust refer to an existing account in the ledger
const hash = await client.declare({
moniker: "chain-user",
issuer: "<issuer-address>",
wallet,
});With account data
You can also attach some data with the account when creating:
datawill be immutable upon creationdatacan be retrieved withgetAccountStatedatamust be structured in the transaction data formatdatasize can not be too large because transaction size limit.
const hash = await client.declare({
moniker: "chain-user",
data: {
type: "json",
value: {
source: "hello-arcblock-chain",
},
},
wallet,
});Create accounts implicitly
ArcBlock chain also creates accounts implicitly in the following cases so that the user does not need to send DeclareTx ahead:
- Delegate: when the delegation receiver is not in the ledger, it's created
- Transfer: when the receiver is not in the ledger, it's created
But there are some pros for accounts created implicitly:
monikercan not be customizedissuercan not be customizeddatais empty