I have created chaincode in which I want to do multiple transactions. But only one transaction occur.
This is my code:
const { Contract } = require("fabric-contract-api");
const crypto = require("crypto");
class KVContract extends Contract {
constructor() {
super("KVContract");
}
async instantiate() {
// function that will be invoked on chaincode instantiation
}
async test(ctx) {
const chars = "abcdefghijklmnopqrstuvwxyz";
try {
for (let i = 0; i < 100; i++) {
for (let j = 0; j < 10; j++) {
let randomString = chars.charAt(
Math.floor(Math.random() * chars.length)
);
await ctx.stub.putState(`key${i}`, Buffer.from(randomString));
}
}
return { success: "OK" };
} catch (error) {
return { success: JSON.stringify(error) };
}
}
exports.contracts = [KVContract];
Is there a way to execute multiple putState or transactions in a chaincode. Like i want to do 100 transactions once