Skip to content

Commit

Permalink
Gen keys example
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbutz committed Aug 18, 2021
1 parent 9c6c6dd commit cda5a2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions fiosdk-generate-keypair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { FIOSDK } = require('@fioprotocol/fiosdk')

const mnemonicExample = 'valley alien library bread worry brother bundle hammer loyal barely dune brave',
privateKeyExample = '5Kbb37EAqQgZ9vWUHoPiC2uXYhyGSFNbL6oiDp24Ea1ADxV1qnu',
publicKeyExample = 'FIO5kJKNHwctcfUM5XZyiWSqSTM5HTzznJP9F3ZdbhaQAHEVq575o',
accountExample = 'ltwagbt4qpuk'

const genKeys = async () => {

const keyRes = await FIOSDK.createPrivateKeyMnemonic(mnemonicExample);
const privateKey = keyRes.fioKey;
const publicKey = FIOSDK.derivedPublicKey(privateKey).publicKey;

account = FIOSDK.accountHash(publicKey).accountnm;
console.log('acct: ', account)

console.log(`Private Key: ${privateKey} // Expect it to be: ${privateKeyExample}`);
console.log(`Public Key: ${publicKey} // Expect it to be: ${publicKeyExample}`);
console.log(`Account: ${account} // Expect it to be: ${accountExample}`);

// See this testnet account on the FIO Explorer: https://fio-test.bloks.io/account/ltwagbt4qpuk

}

genKeys();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fiosdk_typescript-examples",
"version": "1.0.0",
"dependencies": {
"@fioprotocol/fiosdk": "^1.2.0",
"@fioprotocol/fiosdk": "^1.3.0",
"node-fetch": "^2.6.1"
}
}

0 comments on commit cda5a2f

Please sign in to comment.