Skip to content

invoking qscc contract function from another contract #536

@sami96h

Description

@sami96h

Im trying to retrieve transaction details using the GetTransactionByID function , but im getting this error
=> "Rejecting invoke of QSCC from another chaincode because of potential for deadlocks, original invocation for 'demo-contract'"

Here is the code :
async GetAllResults(ctx, iterator) {
let allResults = [];
let res = { done: false, value: null };

    while (true) {
        res = await iterator.next();
        let jsonRes = {};
        if (res.value && res.value.value.toString()) {

            jsonRes.TxId = res.value.txId;
            const response= await ctx.stub.invokeChaincode('qscc',['GetTransactionByID',res.value.txId])
            jsonRes.test=response
            jsonRes.Timestamp = res.value.timestamp;
            jsonRes.Timestamp = new Date((res.value.timestamp.seconds.low * 1000));
            let ms = res.value.timestamp.nanos / 1000000;
            jsonRes.Timestamp.setMilliseconds(ms);
            if (res.value.is_delete) {
                jsonRes.IsDelete = res.value.is_delete.toString();
            } else {
                try {
                    jsonRes.Value = JSON.parse(res.value.value.toString('utf8'));

                } catch (err) {
                    console.log(err);
                    jsonRes.Value = res.value.value.toString('utf8');
                }
            }

            allResults.push(jsonRes);
        }
        if (res.done) {

            await iterator.close();
            return allResults;
        }

    }  
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions