Dev document

1 Download

release version, please waiting

dev versionarrow-up-right

2 Preparation

2.1 Interaction Flow

  • 1.Make sure the user get the Extension

  • 2.Connect the blockchain

  • 3.Initialize contract / Call the methods of the blockchain

  • 4.Call the methods of contract

2.2 Demo of Checking the Extension

let nightElfInstance = null;
class NightElfCheck {
    constructor() {
        const readyMessage = 'NightElf is ready';
        let resovleTemp = null;
        this.check = new Promise((resolve, reject) => {
            if (window.NightElf) {
                resolve(readyMessage);
            }
            setTimeout(() => {
                reject({
                    error: 200001,
                    message: 'timeout / can not find NightElf / please install the extension'
                });
            }, 1000);
            resovleTemp = resolve;
        });
        document.addEventListener('NightElf', result => {
            console.log('test.js check the status of extension named nightElf: ', result);
            resovleTemp(readyMessage);
        });
    }
    static getInstance() {
        if (!nightElfInstance) {
            nightElfInstance = new NightElfCheck();
            return nightElfInstance;
        }
        return nightElfInstance;
    }
}
const nightElfCheck = NightElfCheck.getInstance();
nightElfCheck.check.then(message => {
    // connectChain -> Login -> initContract -> call contract methods
});

2.3 How Connect the blockchain

2.4 How to call the API

Callback or promise are both ok.

3 API Reference

Here you can find examples and in-depth information about NightELF's API.

You can see the demo code. click herearrow-up-right

If you want to check token transfer demo. click herearrow-up-right

The methods act the same as the methods of the aelf-sdk.js

3.1 LOGIN

LOGIN allows your application to request permission to interact with a user's NightELF and be provided with an account of the user's choosing.

3.2 GET_CHAIN_STATUS

3.3 CALL_AELF_CHAIN

3.4 INIT_AELF_CONTRACT

3.5 CALL_AELF_CONTRACT / CALL_AELF_CONTRACT_READONLY

3.6 CHECK_PERMISSION

CHECK_PERMISSION returns the contracts your can use with the address.

3.7 SET_CONTRACT_PERMISSION

SET_CONTRACT_PERMISSION applies to the users to allow the Dapp use the contract.

3.8 REMOVE_CONTRACT_PERMISSION

3.9 REMOVE_METHODS_WHITELIST

3.10 GET_SIGNATURE

4.For Extension Developers

4.1. Download the code

4.2 Install dependent

4.3 Run webpack

4.4 Add to the browser

4.5 How to publish to chrome

zip app/public to public.zip, and follow the notes.

4.6 Can not use crx

You can not install the extension from an offline crx if Chrome >= 73.

Please import the .zip file with developer mode.

5 Formatted Data Example

Last updated

Was this helpful?