向锯齿账本提交交易时的无效状态

时间:2020-03-23 10:11:19

标签: blockchain hyperledger hyperledger-sawtooth

我正在使用“ hyperledger / sawtooth-rest-api:1.0”泊坞窗。我试图创建一个简单的事务并将其提交,但是当我检查该事务的状态时,它会给出以下响应。

“邮件”:“无法反序列化有效负载”

“状态”:“无效”

我的有效载荷是

const payload = {
    Verb: 'set',
    Name: 'Fqa',
    Value: 31
}

我的交易标头是

const transactionHeaderBytes = protobuf.TransactionHeader.encode({
    familyName: 'supply_chain',
    familyVersion: '1.1',
    // inputs: ['3400de'],
    // outputs: ['3400de'],
    nonce: (Math.random() * 10 ** 18).toString(36),
    signerPublicKey: signer.getPublicKey().asHex(),
    batcherPublicKey: signer.getPublicKey().asHex(),
    dependencies: [],
    payloadSha512: createHash('sha512').update(payloadBytes).digest('hex')
 }).finish()

我尝试了相同的事务头,但未注释输入和输出。但是在这两次中,我都遇到了同样的错误,指出状态无效

我的其余代码在下面给出

const signature = signer.sign(transactionHeaderBytes)

const transaction = protobuf.Transaction.create({
    header: transactionHeaderBytes,
    headerSignature: signature,
    payload: payloadBytes
})

const transactions = [transaction]

const batchHeaderBytes = protobuf.BatchHeader.encode({
    signerPublicKey: signer.getPublicKey().asHex(),
    transactionIds: transactions.map((txn) => txn.headerSignature),
}).finish()

const signatureHeader = signer.sign(batchHeaderBytes)

const batch = protobuf.Batch.create({
    header: batchHeaderBytes,
    headerSignature: signatureHeader,
    transactions: transactions
})

const batchListBytes = protobuf.BatchList.encode({
    batches: [batch]
}).finish()

0 个答案:

没有答案