Sawtooth Javascript SDK "Batchlist rejected" error

0 votes

I want to do some specific task using Javascript Sdk of sawtooth in Node Js but unable to run it successfully. Please find the code below, am getting this error as below. 

Can someone help me solve this error?

//Errror

{
  "error": {
    "code": 30,
    "message": "The submitted BatchList was rejected by the validator. It was poorly formed, or has an invalid signature.",
    "title": "Submitted Batches Invalid"
  }
}

//Code

const {createContext, CryptoFactory} = require('sawtooth-sdk/signing')

const context = createContext('secp256k1')
const privateKey = context.newRandomPrivateKey();

const signer = new CryptoFactory(context).newSigner(privateKey)
const cbor = require('cbor')

const payload = {
    Verb: 'set',
    Name: 'foo',
    Value: 42
}

const payloadBytes = cbor.encode(payload)
const {createHash} = require('crypto')
const {protobuf} = require('sawtooth-sdk')
const transactionHeaderBytes = protobuf.TransactionHeader.encode({
    familyName: 'intkey',
    familyVersion: '1.0',
    inputs: [createHash('sha512').update("intkey").digest('hex')],
    outputs: [createHash('sha512').update("intkey").digest('hex')],
    signerPublicKey: signer.getPublicKey().asHex(),
    // In this example, we're signing the batch with the same private key,
    // but the batch can be signed by another party, in which case, the
    // public key will need to be associated with that key.
    batcherPublicKey: signer.getPublicKey().asHex(),
    // In this example, there are no dependencies.  This list should include
    // an previous transaction header signatures that must be applied for
    // this transaction to successfully commit.
    // For example,
    // dependencies: ['540a6803971d1880ec73a96cb97815a95d374cbad5d865925e5aa0432fcf1931539afe10310c122c5eaae15df61236079abbf4f258889359c4d175516934484a'],
    dependencies: [],
    payloadSha512: createHash('sha512').update(payloadBytes).digest('hex')
}).finish()
const signature = signer.sign(transactionHeaderBytes);
Sep 19, 2018 in Blockchain by slayer
• 29,040 points
84 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

What you can do is use intkey-client to the access intkey processor, here's a github repo for that:

https://github.com/thegreatsunra/intkey-client-js

answered Sep 19, 2018 by digger
• 27,620 points

Related Questions In Blockchain

+1 vote
1 answer
0 votes
3 answers

Hyperledger fabcar sample fabric error: sendPeersProposal - Promise is rejected: Error: Connect Failed

Open the datasources.json file and replace the grpcs:// with grpc://. This solution worked ...READ MORE

answered Apr 30 in Blockchain by Reshma
625 views
0 votes
1 answer

sendProposal - timed out after:45000, sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT

You could simply replace --net=bridge with --net=artifacts_default in your DockerFile.  I used ...READ MORE

answered Jul 26, 2018 in Blockchain by Perry
• 16,450 points
234 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,620 points
38 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.