account_create_implicit_account
Generate a random keypair on NEAR to create an implicit account, useful for adding access keys to an existing account.
Instructions
Create an implicit account on the NEAR blockchain. An implicit account is a new random keypair that is not associated with an account ID. Instead the account ID is derived from the public key of the keypair (a 64-character lowercase hexadecimal representation of the public key). This implicit account id can be used just as a regular account id, but remember it is not an official account id with a .near or .testnet suffix. Creating implicit accounts is useful for adding new access keys to an existing account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| networkId | No | mainnet |
Implementation Reference
- src/services.ts:1142-1191 (registration)Registration of the 'account_create_implicit_account' tool via mcp.tool() call, including its description, input schema (networkId), and handler function.
mcp.tool( 'account_create_implicit_account', noLeadingWhitespace` Create an implicit account on the NEAR blockchain. An implicit account is a new random keypair that is not associated with an account ID. Instead the account ID is derived from the public key of the keypair (a 64-character lowercase hexadecimal representation of the public key). This implicit account id can be used just as a regular account id, but remember *it is not* an official account id with a .near or .testnet suffix. Creating implicit accounts is useful for adding new access keys to an existing account. `, { networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), }, async (args, _) => { const keyPair = KeyPair.fromRandom('ed25519'); const publicKey = keyPair.getPublicKey().toString(); const implicitAccountIdResult: Result<string, Error> = (() => { try { return { ok: true, value: Buffer.from( base58.decode(publicKey.split(':')[1]!), ).toString('hex'), }; } catch (e) { return { ok: false, error: new Error(e as string) }; } })(); if (!implicitAccountIdResult.ok) { return { content: [ { type: 'text', text: `Error: ${implicitAccountIdResult.error}` }, ], }; } const implicitAccountId = implicitAccountIdResult.value; await keystore.setKey(args.networkId, implicitAccountId, keyPair); return { content: [ { type: 'text', text: stringify_bigint({ networkId: args.networkId, implicitAccountId, publicKey, }), }, ], }; }, ); - src/services.ts:1153-1190 (handler)The handler function for account_create_implicit_account. It generates a random ED25519 keypair, derives the implicit account ID by base58-decoding the public key and converting to hex, stores the keypair in the keystore, and returns the network ID, implicit account ID, and public key.
async (args, _) => { const keyPair = KeyPair.fromRandom('ed25519'); const publicKey = keyPair.getPublicKey().toString(); const implicitAccountIdResult: Result<string, Error> = (() => { try { return { ok: true, value: Buffer.from( base58.decode(publicKey.split(':')[1]!), ).toString('hex'), }; } catch (e) { return { ok: false, error: new Error(e as string) }; } })(); if (!implicitAccountIdResult.ok) { return { content: [ { type: 'text', text: `Error: ${implicitAccountIdResult.error}` }, ], }; } const implicitAccountId = implicitAccountIdResult.value; await keystore.setKey(args.networkId, implicitAccountId, keyPair); return { content: [ { type: 'text', text: stringify_bigint({ networkId: args.networkId, implicitAccountId, publicKey, }), }, ], }; }, - src/services.ts:1150-1152 (schema)Input schema for account_create_implicit_account: takes a single optional 'networkId' parameter ('testnet' or 'mainnet', defaulting to 'mainnet').
{ networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), },