Neo3 provider API

The NeoLine extension wallet injects an Neo N3 provider into the browser at window.NEOLineN3.

You can use this provider in your dapp to request users' Neo N3 accounts, read on-chain data, and have the user sign messages and transactions.

If you need to call the N3 dAPI monitoring method, you need to initialize NEOLine after initializing NEOLineN3, please refer to the example on the right.

let neoline;
let neolineN3;

function initDapi() {
    const initCommonDapi = new Promise((resolve, reject) => {
        window.addEventListener('NEOLine.NEO.EVENT.READY', () => {
            neoline = new NEOLine.Init();
            if (neoline) {
                resolve(neoline);
            } else {
                reject('common dAPI method failed to load.');
            }
        });
    });
    const initN3Dapi = new Promise((resolve, reject) => {
        window.addEventListener('NEOLine.N3.EVENT.READY', () => {
            neolineN3 = new NEOLineN3.Init();
            if (neolineN3) {
                resolve(neolineN3);
            } else {
                reject('N3 dAPI method failed to load.');
            }
        });
    });
    initCommonDapi.then(() => {
        console.log('The common dAPI method is loaded.');
        return initN3Dapi;
    }).then(() => {
        console.log('The N3 dAPI method is loaded.');
    }).catch((err) => {
        console.log(err);
    })
};

initDapi();

最后更新于