Skip to content

Is there any available options to get an near-api-js Account object from wallet? #559

Answered by amirsaran3
kostyamospan asked this question in Q&A
Discussion options

You must be logged in to vote

@kostyamospan wallet-selector just gives you the account id which you can access like this: selector.store.getState().accounts. We don't give you the Account object because not all wallets are using it like that.

You can construct the Account object using the account id like this:

import { connect } from "near-api-js";

const near = await connect({...});
const accountId = selector.store.getState().accounts[0];
const account = await near.account(accountId);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amirsaran3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants