MCPcopy Create free account
hub / github.com/PolymathNetwork/polymath-core / send_poly

Function send_poly

CLI/commands/faucet.js:42–93  ·  view source on GitHub ↗
(beneficiary, amount)

Source from the content-addressed store, hash-verified

40}
41
42async function send_poly(beneficiary, amount) {
43 let issuerBalance = await polyToken.methods.balanceOf(Issuer.address).call({from : Issuer.address});
44 console.log(chalk.blue(`Hello User, your current balance is '${(new BigNumber(issuerBalance).dividedBy(new BigNumber(10).pow(18))).toNumber()} POLY'\n`))
45
46 if (typeof beneficiary === 'undefined' && typeof amount === 'undefined') {
47 let options = ['250 POLY for ticker registration','500 POLY for token launch + ticker reg', '20K POLY for CappedSTO Module',
48 '20.5K POLY for Ticker + Token + CappedSTO', '100.5K POLY for Ticker + Token + USDTieredSTO','As many POLY as you want', '10K USD Tokens'];
49 index = readlineSync.keyInSelect(options, 'What do you want to do?');
50 console.log("Selected:", index != -1 ? options[index] : 'Cancel');
51 switch (index) {
52 case 0:
53 beneficiary = readlineSync.question(`Enter beneficiary of 250 POLY ('${Issuer.address}'): `);
54 amount = '250';
55 break;
56 case 1:
57 beneficiary = readlineSync.question(`Enter beneficiary of 500 POLY ('${Issuer.address}'): `);
58 amount = '500';
59 break;
60 case 2:
61 beneficiary = readlineSync.question(`Enter beneficiary of 20K POLY ('${Issuer.address}'): `);
62 amount = '20000';
63 break;
64 case 3:
65 beneficiary = readlineSync.question(`Enter beneficiary of 20.5K POLY ('${Issuer.address}'): `);
66 amount = '20500';
67 break;
68 case 4:
69 beneficiary = readlineSync.question(`Enter beneficiary of 100.5K POLY ('${Issuer.address}'): `);
70 amount = '100500';
71 break;
72 case 5:
73 beneficiary = readlineSync.question(`Enter beneficiary of transfer ('${Issuer.address}'): `);
74 amount = readlineSync.questionInt(`Enter the no. of POLY Tokens: `).toString();
75 break;
76 case 6:
77 beneficiary = readlineSync.question(`Enter beneficiary 10K USD Tokens ('${Issuer.address}'): `);
78 if (beneficiary == "") beneficiary = Issuer.address;
79 let getTokensAction = usdToken.methods.getTokens(web3.utils.toWei('10000'), beneficiary);
80 await common.sendTransaction(getTokensAction);
81 let balance = await usdToken.methods.balanceOf(beneficiary).call();
82 let balanceInPoly = new BigNumber(balance).dividedBy(new BigNumber(10).pow(18));
83 console.log(chalk.green(`Congratulations! balance of ${beneficiary} address is ${balanceInPoly.toNumber()} USD Tokens`));
84 process.exit(0);
85 break;
86 case -1:
87 process.exit(0);
88 }
89 }
90
91 if (beneficiary == "") beneficiary = Issuer.address;
92 await transferTokens(beneficiary, web3.utils.toWei(amount));
93}
94
95async function transferTokens(to, amount) {
96 try {

Callers 1

executeAppFunction · 0.85

Calls 1

transferTokensFunction · 0.85

Tested by

no test coverage detected