Last active
June 7, 2021 08:20
-
-
Save ilyar/a2a7b82153c172ddb565ac109ae24e11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as near from '@4ire-labs/near-sdk' // const near = require('@4ire-labs/near-sdk') | |
| process.env.NEAR_ENV = 'testnet' | |
| async function main() { | |
| const account = await near.readUnencryptedFileSystemKeyStore(near.accountIdBySlug('ilyar')) | |
| console.log(account) | |
| console.log('Account:', { | |
| implicitId: account.accountId, | |
| publicKey: account.keyPair.publicKey.toString(), | |
| hasSecretKey: account.keyPair.secretKey.length === 88, | |
| }) | |
| const connect = await near.newAccountConnect(account) | |
| const mnemonic = near.generateMnemonic() // near.generateMnemonic(Buffer.from('0123456789ABCDEF')) | |
| const newAccount = near.mnemonicToAccount(mnemonic) | |
| console.log('Implicit Account:', { // https://docs.near.org/docs/roles/integrator/implicit-accounts | |
| mnemonic: mnemonic, | |
| implicitId: newAccount.accountId, | |
| publicKey: newAccount.keyPair.publicKey.toString(), | |
| }) | |
| const outcomeRaw = await connect.addKey(newAccount.keyPair.publicKey) | |
| const outcome = near.transactionOutcome(outcomeRaw) | |
| console.log('Sender Account:', { | |
| transactionId: outcome.transactionId, | |
| }) | |
| } | |
| main().catch(console.error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment