1+ var arkjs = require ( "arkjs" ) ;
2+ var fs = require ( 'fs' ) ;
3+ var XMLHttpRequest = require ( "xmlhttprequest" ) . XMLHttpRequest ;
4+
5+ module . exports = {
6+ CheckAddress : function ( address ) {
7+ return arkjs . crypto . validateAddress ( address , 115 ) ;
8+ } ,
9+ SendOSM : function ( address ) {
10+ let wallet = JSON . parse ( fs . readFileSync ( 'config.json' , 'utf8' ) ) . faucetWallet ;
11+ let nethash = "fa976091894eee4cad258bdae4e3323d0768c4f8610e471237408ac4aa0a92d0" ;
12+ let sender = arkjs . crypto . getKeys ( wallet ) ;
13+ let amountSatoshi = 1000 * Math . pow ( 10 , 8 ) ;
14+
15+ let transaction = arkjs . transaction . createTransaction ( address , amountSatoshi , "Courtesy of our faucet" , sender , undefined , 115 ) ;
16+
17+ let transactions = {
18+ transactions : [ transaction ]
19+ }
20+
21+ let http = new XMLHttpRequest ( ) ;
22+ let url = 'http://blockchain.osmose.world:4100/peer/transactions' ;
23+ http . open ( 'POST' , url , true ) ;
24+ http . setRequestHeader ( "nethash" , nethash ) ;
25+ http . setRequestHeader ( "version" , "1.6.0" ) ;
26+ http . setRequestHeader ( "port" , "1" ) ;
27+
28+ //Send the proper header information along with the request
29+ http . setRequestHeader ( "Content-Type" , "application/json" ) ;
30+
31+ http . onreadystatechange = function ( ) {
32+ if ( http . readyState === 4 && http . status === 200 ) {
33+ console . log ( new Date ( ) + " | 1000 OSM sent from : " + arkjs . crypto . getAddress ( sender . publicKey , 115 ) + " --> " + address ) ;
34+ }
35+ } ;
36+
37+ http . send ( JSON . stringify ( transactions ) ) ;
38+ }
39+ } ;
0 commit comments