Skip to content
Cive

privateKeyToAccount

A Private Key Account is an interface that has the ability to sign transactions and messages with a given private key.

Import

import {  } from "cive/accounts";

Usage

To initialize a Private Key Account, you will need to pass a private key to privateKeyToAccount:

import { ,  } from "cive";
import {  } from "cive/accounts";
import {  } from "cive/chains";
 
const  = (
  "0x...", 
  { : . } 
);
 
const  = ({
  ,
  : ,
  : (),
});

Generating Private Keys

You can generate a random private key using the generatePrivateKey function:

import {  } from "cive/accounts";
 
const  = ();

Parameters

privateKey

  • Type: Hex

The private key to use for the Account.

address

The address of the Account.

const  = (
  "0xb8f3864b49115f1eec4868dbb19d3a406d152f6e18292d8aa300989f681442a3", 
  { : . } 
);
 
.;
// 'cfx:aakcrjzwbmguzj92tm11yegsr26ja93hj2h10sa7r4'

options.networkId

The network id of the Account.

const  = (
  "0xb8f3864b49115f1eec4868dbb19d3a406d152f6e18292d8aa300989f681442a3",
  {
    : ., 
  }
);
 
.;
// 'cfx:aakcrjzwbmguzj92tm11yegsr26ja93hj2h10sa7r4'