getProvider

Returns information about the dAPI provider, including who this provider is, the version of their dAPI, and the NEP that the interface is compatible with.

Input Arguments

None

Success Response

ParameterDescription

name: string

The name of the wallet provider

website: string

The website of the wallet provider

version: string

The version of the dAPI that the the wallet supports

compatibility: string[]

A list of all applicable NEPs which the wallet provider supports

extra: object

This object can contain any attributes specific to the dapi provider, such as an app theme

Error Response

ParameterDescription

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.getProvider()
.then(provider => {
    const {
        name,
        website,
        version,
        compatibility,
        extra
    } = provider;

    console.log('Provider name: ' + name);
    console.log('Provider website: ' + website);
    console.log('Provider dAPI version: ' + version);
    console.log('Provider dAPI compatibility: ' + JSON.stringify(compatibility));
    console.log('Extra provider specific atributes: ' + JSON.stringify(compatibility));
})
.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;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

Response

{
    name: 'Awesome Wallet',
    website: 'https://www.neoline.io/',
    version: '1.0.0',
    compatibility: [],
    extra: {}
}

最后更新于