Skip to main content

Register an account

  1. Ensure you are in dcloud_example directory.

  2. Start up register.js in terminal using the following command to register an account:

    node register.js

    Code example and comments:

    register.js
    import { 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 the dcloud_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.