@@ -18,23 +18,73 @@ window.addEventListener('load', async () => {
18
18
// Instantiate the API
19
19
const polymathAPI = new PolymathAPI ( params ) ;
20
20
21
- const ticker = 'TEST' ;
22
- const tokenAddress = await polymathAPI . securityTokenRegistry . getSecurityTokenAddress ( ticker ) ;
23
- const TEST = await polymathAPI . tokenFactory . getSecurityTokenInstanceFromAddress ( tokenAddress ) ;
24
- const investorAddress = '<investor address>' . toLowerCase ( ) ;
25
- const generalTMAddress = ( await TEST . getModulesByName ( { moduleName : ModuleName . GeneralTransferManager } ) ) [ 0 ] ;
21
+ // Get some poly tokens in your account and the security token
22
+ const myAddress = await polymathAPI . getAccount ( ) ;
23
+ await polymathAPI . getPolyTokens ( { amount : new BigNumber ( 1000000 ) , address : myAddress } ) ;
24
+
25
+ // Prompt to setup your ticker and token name
26
+ const ticker = prompt ( 'Ticker' , '' ) ;
27
+ const tokenName = prompt ( 'Token Name' , '' ) ;
28
+
29
+ // Double check available
30
+ await polymathAPI . securityTokenRegistry . isTickerAvailable ( {
31
+ ticker : ticker ! ,
32
+ } ) ;
33
+ // Get the ticker fee and approve the security token registry to spend
34
+ const tickerFee = await polymathAPI . securityTokenRegistry . getTickerRegistrationFee ( ) ;
35
+ await polymathAPI . polyToken . approve ( {
36
+ spender : await polymathAPI . securityTokenRegistry . address ( ) ,
37
+ value : tickerFee ,
38
+ } ) ;
39
+ // Register a ticker
40
+ await polymathAPI . securityTokenRegistry . registerTicker ( {
41
+ ticker : ticker ! ,
42
+ tokenName : tokenName ! ,
43
+ } ) ;
44
+ // Get the st launch fee and approve the security token registry to spend
45
+ const securityTokenLaunchFee = await polymathAPI . securityTokenRegistry . getSecurityTokenLaunchFee ( ) ;
46
+ await polymathAPI . polyToken . approve ( {
47
+ spender : await polymathAPI . securityTokenRegistry . address ( ) ,
48
+ value : securityTokenLaunchFee ,
49
+ } ) ;
50
+
51
+ await polymathAPI . securityTokenRegistry . generateNewSecurityToken ( {
52
+ name : tokenName ! ,
53
+ ticker : ticker ! ,
54
+ tokenDetails : 'details' ,
55
+ divisible : true ,
56
+ treasuryWallet : myAddress ,
57
+ protocolVersion : '0' ,
58
+ } ) ;
59
+
60
+ console . log ( 'Security Token Generated' ) ;
61
+
62
+ const tokenAddress = await polymathAPI . securityTokenRegistry . getSecurityTokenAddress ( ticker ! ) ;
63
+ const tickerSecurityTokenInstance = await polymathAPI . tokenFactory . getSecurityTokenInstanceFromAddress ( tokenAddress ) ;
64
+
65
+ const investorAddress = '0x1111111111111111111111111111111111111111' ;
66
+ const generalTMAddress = ( await tickerSecurityTokenInstance . getModulesByName ( {
67
+ moduleName : ModuleName . GeneralTransferManager ,
68
+ } ) ) [ 0 ] ;
26
69
27
70
const generalTM = await polymathAPI . moduleFactory . getModuleInstance ( {
28
71
name : ModuleName . GeneralTransferManager ,
29
72
address : generalTMAddress ,
30
73
} ) ;
31
74
75
+ await generalTM . modifyKYCData ( {
76
+ investor : investorAddress ,
77
+ canReceiveAfter : new Date ( ) ,
78
+ canSendAfter : new Date ( ) ,
79
+ expiryTime : new Date ( 2035 , 1 ) ,
80
+ } ) ;
81
+
32
82
const listInvestors = await generalTM . getAllKYCData ( ) ;
33
83
const found = listInvestors . find ( function ( addr ) {
34
84
return addr . investor == investorAddress ;
35
85
} ) ;
36
86
37
- await TEST . subscribeAsync ( {
87
+ await tickerSecurityTokenInstance . subscribeAsync ( {
38
88
eventName : SecurityTokenEvents . Issued ,
39
89
indexFilterValues : { } ,
40
90
callback : async ( error , log ) => {
@@ -47,17 +97,20 @@ window.addEventListener('load', async () => {
47
97
} ) ;
48
98
49
99
if ( found ) {
50
- await TEST . issue ( {
100
+ await tickerSecurityTokenInstance . issue ( {
51
101
investor : investorAddress ,
52
102
value : new BigNumber ( 100 ) ,
53
- data : '' ,
103
+ data : '0x51 ' ,
54
104
txData : {
55
- from : '<sto owner>' . toLowerCase ( ) ,
105
+ from : myAddress . toLowerCase ( ) ,
56
106
} ,
57
107
} ) ;
108
+ console . log ( '100 tokens issued' ) ;
58
109
} else {
59
110
console . log ( 'Please make sure beneficiary address has been whitelisted' ) ;
60
111
}
112
+ console . log ( 'Balance of investor:' ) ;
113
+ console . log ( ( await tickerSecurityTokenInstance . balanceOf ( { owner : investorAddress } ) ) . toNumber ( ) ) ;
61
114
62
- TEST . unsubscribeAll ( ) ;
115
+ tickerSecurityTokenInstance . unsubscribeAll ( ) ;
63
116
} ) ;
0 commit comments