|
|
|
@@ -3,6 +3,10 @@ import {toUtf8String,parseUnits,ContractFactory, parseEther,JsonRpcProvider, Con |
|
|
|
,Transaction,formatEther, |
|
|
|
ZeroHash,ethers,keccak256 |
|
|
|
} from 'ethers' |
|
|
|
import chalk from "chalk"; |
|
|
|
// import * as chalk from "chalk"; |
|
|
|
// import {foregroundColorNames} from 'chalk'; |
|
|
|
|
|
|
|
import {Calulator} from "../inc/calc"; |
|
|
|
import { TokenIssuer } from "../inc/TokenIssuer"; |
|
|
|
import { |
|
|
|
@@ -59,9 +63,10 @@ async function transfer(symbol:string,from: Wallet, to: Wallet, amount: number = |
|
|
|
console.log('holder kyc error'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const partitions = await token.getDefaultPartitions(); |
|
|
|
console.log('###################### 전송전 ###################################') |
|
|
|
console.log(`balance of sender = ${balance1}, balance of receiver = ${balance2}`); |
|
|
|
console.log(chalk.yellow('###################### 전송전 잔고 ###################################')) |
|
|
|
console.log(`balance of sender(${from.address}) = ${balance1}\r\nbalance of receiver(${to.address}) = ${balance2}`); |
|
|
|
|
|
|
|
// token.on(token.filters.Transfer, async (...args) => { |
|
|
|
// const lastArg = args[args.length - 1]; |
|
|
|
@@ -77,9 +82,10 @@ async function transfer(symbol:string,from: Wallet, to: Wallet, amount: number = |
|
|
|
let lastTx:string = null; |
|
|
|
const start = Date.now(); |
|
|
|
|
|
|
|
//console.log(`전송시작 시간 : `,new Date(start)); |
|
|
|
console.log(chalk.cyan(`전송시작 시간 : ${new Date(start).toUTCString()}`)); |
|
|
|
|
|
|
|
|
|
|
|
console.log(`sending ${count} transactions`); |
|
|
|
console.log(chalk.yellow(`sending ${count} transactions`)); |
|
|
|
for(let i = 0; i < count; i++) { |
|
|
|
const tx = await token.operatorTransferByPartition.populateTransaction( |
|
|
|
partitions[0], |
|
|
|
@@ -130,20 +136,22 @@ async function transfer(symbol:string,from: Wallet, to: Wallet, amount: number = |
|
|
|
const lastBlockHash = blockHashes.get(lastTx); |
|
|
|
console.log(`firstBlockHash = ${firstBlockHash} \nlastBlockHash = ${lastBlockHash}`); |
|
|
|
|
|
|
|
const lastB = await getBlockInfo(lastBlockHash); |
|
|
|
// console.log(lastB.timestamp); |
|
|
|
const lastTimeStamp = parseInt(lastB.timestamp,16); |
|
|
|
|
|
|
|
balance1= await token.balanceOf(from); |
|
|
|
balance2 = await token.balanceOf(to); |
|
|
|
console.log(`balance of sender = ${balance1}, balance of receiver = ${balance2}`); |
|
|
|
console.log(chalk.yellow('###################### 전송후 잔고 ###################################')) |
|
|
|
console.log(`balance of sender(${from.address}) = ${balance1}\r\nbalance of receiver(${to.address}) = ${balance2}`); |
|
|
|
// console.log(`balance of sender = ${balance1}, balance of receiver = ${balance2}`); |
|
|
|
|
|
|
|
|
|
|
|
const lastB = await getBlockInfo(lastBlockHash); |
|
|
|
const lastTimeStamp = parseInt(lastB.timestamp,16); |
|
|
|
console.log(`eth_getBlockByHash(${lastBlockHash}).timestamp = ${lastTimeStamp}`) |
|
|
|
|
|
|
|
const d = new Date(lastTimeStamp * 1000); |
|
|
|
console.log(d); |
|
|
|
console.log(chalk.cyan(`전송종료 시간(블록완결시간) : ${d.toUTCString()}`)); |
|
|
|
|
|
|
|
console.log(start); |
|
|
|
console.log(lastTimeStamp * 1000); |
|
|
|
console.log(chalk.yellow(`start timestamp = ${start}`)); |
|
|
|
console.log(chalk.yellow(`end timestamp = ${lastTimeStamp * 1000}`)); |
|
|
|
|
|
|
|
const tps = calc.CTPS(count,start,lastTimeStamp * 1000); |
|
|
|
console.log(`CTPS = ${tps}`); |
|
|
|
@@ -162,16 +170,11 @@ const admin = new Wallet('0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9e |
|
|
|
const issuer = new Wallet('0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63',provider); |
|
|
|
// const signer = new Wallet('0x55d1000aa2057a878b5f7902158615f889cb1e9b811f7e1e9c0b4518399ba84a',provider); |
|
|
|
const signer = issuer; |
|
|
|
|
|
|
|
const holder1 = new Wallet('0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f',provider); |
|
|
|
const holder2 = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',provider); |
|
|
|
|
|
|
|
async function main() { |
|
|
|
// console.log(admin); |
|
|
|
// console.log(issuer); |
|
|
|
console.log(holder1); |
|
|
|
console.log(holder2); |
|
|
|
transfer('test001',holder2, holder1,1, 1000); |
|
|
|
transfer('test001',holder2, holder1,1, 1000); |
|
|
|
} |
|
|
|
|
|
|
|
main(); |