Skip to content

Instantly share code, notes, and snippets.

@mattlockyer
Created April 17, 2021 21:00
Show Gist options
  • Select an option

  • Save mattlockyer/39e70070fa1b51d4a9b31fadae99052f to your computer and use it in GitHub Desktop.

Select an option

Save mattlockyer/39e70070fa1b51d4a9b31fadae99052f to your computer and use it in GitHub Desktop.

Revisions

  1. mattlockyer created this gist Apr 17, 2021.
    16 changes: 16 additions & 0 deletions sign-for-user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import * as nearAPI from 'near-api-js';

    const {
    Account,
    KeyPair,
    } = nearAPI;

    // near is your current near connection instance (somewhere in your app init)

    export const getAccessKeyAccount = (near, accountId, secretKey) => {
    const keyPair = KeyPair.fromString(secretKey);
    near.connection.signer.keyStore.setKey(near.config.networkId, accountId, keyPair);
    const account = new Account(near.connection, accountId);
    return account;
    };