Register an account
-
Ensure you are in
dcloud_example
directory, and you have installed the Power SDK. -
Execute the following command:
yarn
-
Start up
register.js
in terminal using the following command to register an account:- npm
- Yarn
- pnpm
node register.js
node register.js
node register.js
Code example and comments:
register.jsimport { NetworkApi, WalletApi } from '@thepowereco/tssdk';
import {writeFileSync} from 'fs';
//register in chain number 1033
let acc = await WalletApi.registerCertainChain(1033);
console.log('register data',acc);
//save account data to file
const networkApi = new NetworkApi(1033);
const walletApi = new WalletApi(networkApi);
let password='111';
let hint='three one';
const exportedData = walletApi.getExportData(acc.wif, acc.address, password, hint);
writeFileSync('example.pem', exportedData);The information about the registered account will be displayed in the terminal (console), and the file
example.pem
will appear in thedcloud_example
directory:dcloud_example % node index.js
register data {
chain: 1033,
wif: 'KywHx4qhG49JEms15jmgXDGMq7xKkmhQSpiZihWi5bbvL8QvjyUD',
address: 'AA100001733086414002',
seed: 'resource butter table ivory try churn banner toilet depart camera peace decide'
}
info
You can find your actual account address in address
field. You will need it in the next tasks.
Now you can work with transactions and smart contracts.