Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

start.ts 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import * as dotevnv from "dotenv"
  2. import {toUtf8String,parseUnits,ContractFactory, parseEther,JsonRpcProvider, Contract, JsonRpcSigner, Wallet,ContractTransactionResponse, MaxInt256
  3. ,Transaction,formatEther,
  4. ZeroHash,ethers,keccak256
  5. } from 'ethers'
  6. import chalk from "chalk";
  7. import {Calulator} from "../inc/calc";
  8. import { TokenIssuer } from "../inc/TokenIssuer";
  9. import {
  10. SecurityToken,
  11. SecurityToken__factory,
  12. } from '../typechain'
  13. // import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
  14. import {checkReceipt,checkReceipt2, setProvider,getDeploymentAddresses,
  15. getElapsed, sleep,getBlockInfo} from '../inc/util'
  16. import { sign } from "crypto";
  17. dotevnv.config();
  18. if (!process.env.RPCURL) {
  19. console.log(`No rpcur value specified...`)
  20. }
  21. console.log(`목적 서버 : ${process.env.RPCURL}`);
  22. async function getNonce(addr: string): Promise<number> {
  23. const nonce = await provider.getTransactionCount(addr);
  24. return nonce;
  25. }
  26. async function getTransferData(symbol:string,from: Wallet, to: Wallet, amount: number = 1): Promise<any> {
  27. const proxy = getDeploymentAddresses(symbol).address;
  28. console.log(`토큰 주소 : ${proxy}`);
  29. const token = new SecurityToken__factory(issuer).attach(proxy) as SecurityToken;
  30. const partitions = await token.getDefaultPartitions();
  31. let nonce = await getNonce(signer.address);
  32. const tx = await token.operatorTransferByPartition.populateTransaction(
  33. partitions[0],
  34. from.address,
  35. to.address,
  36. amount,
  37. ZeroHash,
  38. ZeroHash,
  39. {
  40. // gasPrice: 0,
  41. gasLimit: 2100000,
  42. nonce: nonce,
  43. type: 2,
  44. chainId: 1337
  45. }
  46. );
  47. const signed = await signer.signTransaction(tx);
  48. return signed;
  49. }
  50. async function getOperatorGrantData(symbol:string,from: Wallet, to: Wallet, amount: number = 1): Promise<any> {
  51. const proxy = getDeploymentAddresses(symbol).address;
  52. console.log(`토큰 주소 : ${proxy}`);
  53. const token = new SecurityToken__factory(issuer).attach(proxy) as SecurityToken;
  54. //ret = await adminToken.grantRole( id('OPERATOR_ROLE'),tobeOperator,{ gasLimit: 20000000});
  55. }
  56. const calc = new Calulator();
  57. const rpcUrl = process.env.RPCURL;
  58. const provider = new JsonRpcProvider(rpcUrl);
  59. setProvider(provider);
  60. const admin = new Wallet('0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',provider);
  61. const issuer = new Wallet('0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63',provider);
  62. // const signer = new Wallet('0x55d1000aa2057a878b5f7902158615f889cb1e9b811f7e1e9c0b4518399ba84a',provider);
  63. const signer = issuer;
  64. const holder1 = new Wallet('0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f',provider);
  65. const holder2 = new Wallet('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',provider);
  66. async function main() {
  67. const tx = await getTransferData('test001',holder2, holder1,1);
  68. console.log(tx);
  69. }
  70. main();