네, 아래와 같은 코드로 동작시켰고 루프 횟수만 바꿔서 테스트 하였습니다.
let findKeystore = async function(addr) {
let dir = `${process.env.KEYSTOREPATH}`;
let filelist = fs.readdirSync(dir);
let keyaddr = addr.split('0x')[1];
for(let idx = 0; idx < filelist.length; idx++) {
if(filelist[idx].split(keyaddr).length > 1) {
return JSON.parse(fs.readFileSync(dir+'/'+filelist[idx], 'utf-8'));
}
}
return null;
}
let sendSmartContractDeploy = async function(keyring, rawTx, cbHash, cbReceipt, finality) {
try {
if(caver == null || caver == undefined) {
throw new Error("invalid provider!");
}
const tx = caver.transaction.smartContractDeploy.create(rawTx);
await tx.sign(keyring);
if(finality == false) {
caver.rpc.klay.sendRawTransaction(tx)
.on('transactionHash', async function(txHash) {
if(cbHash != null) {
await cbHash(txHash);
}
})
.on('receipt', async function(receipt) {
if(cbReceipt != null) {
await cbReceipt(receipt);
}
});
} else {
await caver.rpc.klay.sendRawTransaction(tx)
.on('transactionHash', async function(txHash) {
if(cbHash != null) {
await cbHash(txHash);
}
})
.on('receipt', async function(receipt) {
if(cbReceipt != null) {
await cbReceipt(receipt);
}
});
}
} catch(error) {
console.log(error);
}
}
let deploy = async function(keyring, nonce, cbHash, cbReceipt, finality) {
try {
let instance = await createContract(abi);
let data = await instance.deploy({data: byteCode}).encodeABI();
let cmder = keyring._address;
let gas = 2000000;
const rawtx = {
from: cmder,
nonce: toHex(nonce),
gas: gas,
data: data};
return deployContract(keyring, rawtx, cbHash, cbReceipt, finality);
} catch(error) {
console.log(error);
return null;
}
}
let deployERC = async function() {
try {
let cmder = process.argv[2];
let passwd = process.argv[3];
let keystore = await findKeystore(cmder);
if (keystore == null) {
throw new Error("Keystore File does not exist!");
}
let keyring = await caver.wallet.keyring.decrypt(keystore, passwd);
if (keyring == null) {
throw new Error("get keyring failed!");
}
let nonce = await caver.rpc.klay.getTransactionCount(keyring._address);
if (nonce == null) {
throw new Error("get nonce failed!");
}
let cbHash = async function(txHash) {
console.log(`Deploy TX:['${colors.green(txHash)}'] Created!`);
}
let cbReceipt = async function(receipt) {
console.log(`TX:['${colors.green(receipt.transactionHash)}'], Nonce:[${colors.green(toNum(receipt.nonce))}], BlockNumber:[${colors.green(parseInt(receipt.blockNumber))}]`);
}
for(let idx = 0; idx < 100000; idx++){
await deploy(keyring, nonce++, cbHash, cbReceipt, false).catch(
function (error) {
console.log(error.message);
}
);
}
return true;
} catch(error) {
console.log(error);
return false;
}
}