Created
April 17, 2021 21:00
-
-
Save mattlockyer/39e70070fa1b51d4a9b31fadae99052f to your computer and use it in GitHub Desktop.
NEAR Protocol - Sign TX as another account using an access key added to that account
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 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; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment