src/api.js
/**
     * Transfer tokens and retrieve the data bought
     * 
     * @param   {String}    identity                                          Buyer Identity's contract address 
     * @param   {String}    seller                                            Seller Identity's contract address
     * @param   {Object[]}  saleNodes                                         List of nodes to be selled 
     * @param   {String}    saleNodes.label                                   Node label
     * @param   {String}    saleNodes.data                                    Node data
     * @param   {String}    saleNodes.salt                                    Node hash's salt
     * @param   {Integer}   price                                             Sale price. 
     * @param   {Object}    [opt={ from: null, gas: null, gasPrice: null }]   transaction options
     * @param   {String}    opt.from                                          set the tx sender
     * @param   {Number}    opt.gas                                           set the tx gas limit
     * @param   {String}    opt.gasPrice                                      set the tx gas price in gwei
     * @returns {Object}                                                      Data bought 
     * @memberof Api
     */
Transfer tokens and retrieve the data bought


Transfer tokens and retrieve the data bought
async buyIdentityData(identity, seller, saleNodes, price, opt = {
        from: null, gas: null, gasPrice: null 
    }) {
        const from = opt.from ? opt.from : this.defaultOptions.from
        const gas = opt.gas ? opt.gas : this.defaultOptions.gas
        const gasPrice = opt.gasPrice ? opt.gasPrice : this.defaultOptions.gasPrice
        if(price > 0) {
            const txData = this.TokenContract.methods.transfer(seller, price).encodeABI()
            await this.forwardTransaction(identity, this.TokenContract.options.address, 0, 0, txData)
        }
        return await this.checkDataTruth(seller, saleNodes)
    }
async buyIdentityData ( identity , seller , saleNodes , price , opt = { from : null , gas : null , gasPrice : null } ) { const from = opt . from ? opt . from : this . defaultOptions . from const gas = opt . gas ? opt . gas : this . defaultOptions . gas const gasPrice = opt . gasPrice ? opt . gasPrice : this . defaultOptions . gasPrice if ( price > 0 ) { const txData = this . TokenContract . methods . transfer ( seller , price ) . encodeABI ( ) await this . forwardTransaction ( identity , this . TokenContract . options . address , 0 , 0 , txData ) } return await this . checkDataTruth ( seller , saleNodes ) }
Transfer tokens and retrieve the data bought
Transfer tokens and retrieve the data bought