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,350 points
898 views

1 answer to this question.

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
• 26,740 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, 2019 in Blockchain by Reshma
2,635 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
• 17,100 points
1,734 views
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,234 views
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
• 26,740 points
726 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP