Account can be used to sign Transaction or Message. Wallet like Fluent can help you manage your accounts (privateKeys) and provide signing functions to you. SDK also provide account manage and signing functions.
Send transaction
// If you want send transaction signed by your own private key, it's need add to wallet before you send transaction
const privateKey = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'; // use your own private key
const account = conflux.wallet.addPrivateKey(privateKey);
await conflux.cfx.sendTransaction({
from: account.address,
to: 'cfxtest:xxxx',
value: 100
});
Random create
// create through wallet
const account = conflux.wallet.addRandom();
// create though PrivateKeyAccount
const { PrivateKeyAccount } = require('js-conflux-sdk');
const networkId = 1;
const randomSeed = '0xfffff'; // any random buffer
const account = PrivateKeyAccount.random(randomSeed, networkId);