For the complete documentation index, see llms.txt. This page is also available as Markdown.

getAccount

Return the Account that is currently connected to the dApp.

Input Arguments

None

Success Response

Parameter
Description

address: string

Address of the connected account

label?: string

A label the users has set to identify their wallet

isLedger: boolean

Whether the connected account is a ledger account

Error Response

Parameter
Description

type: string

The type of error which has occured

description: string

A description of the error which has occured

data: string

Any raw data associated with the error

Example

Request

neolineN3.getAccount()
.then(account => {
    const {
        address,
        label,
        isLedger
    } = account;

    console.log('Provider address: ' + address);
    console.log('Provider account label (Optional): ' + label);
    console.log('Provider account is ledger account: ' + isLedger);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_DENIED':
            console.log('The user rejected the request to connect with your dApp');
            break;
        case 'CHAIN_NOT_MATCH':
            console.log('The currently opened chain does not match the type of the call chain, please switch the chain.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

Response

最后更新于