Simon Lee 1 年之前
父節點
當前提交
afdf25ff52
共有 3 個檔案被更改,包括 50 行新增21 行删除
  1. 21
    18
      TC4/start.ts
  2. 1
    0
      package.json
  3. 28
    3
      yarn.lock

+ 21
- 18
TC4/start.ts 查看文件

@@ -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();

+ 1
- 0
package.json 查看文件

@@ -11,6 +11,7 @@
"dependencies": {
"@types/node": "^22.9.0",
"axios": "^1.7.9",
"chalk": "4.1.2",
"dotenv": "^16.4.5",
"ethers": "^6.13.4",
"hardhat-ethers": "^1.0.1",

+ 28
- 3
yarn.lock 查看文件

@@ -3542,7 +3542,16 @@ string-format@^2.0.0:
resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b"
integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -3567,7 +3576,14 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -3943,7 +3959,16 @@ workerpool@^6.5.1:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

Loading…
取消
儲存