· 6 years ago · Jan 28, 2019, 09:00 PM
1Error: Error: getaddrinfo ENOTFOUND horizon-testnet.stellar.org horizon-testnet.stellar.org:443
2 at _handleNetworkError (/user_code/node_modules/stellar-sdk/lib/call_builder.js:273:31)
3 at process._tickDomainCallback (internal/process/next_tick.js:135:7)
4
5const admin = require('firebase-admin');
6admin.initializeApp();
7
8const StellarSdk = require('stellar-sdk');
9StellarSdk.Network.useTestNetwork();
10var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
11
12var publicKey = 'xxx...';
13var secretKey = 'xxx...';
14var sourceKeyPair = StellarSdk.Keypair.fromSecret(secretKey)
15
16exports.createAccount = functions.https.onCall((data, context) => {
17
18 var newKeyPair = StellarSdk.Keypair.random();
19
20 server.loadAccount(publicKey)
21 .then(function(account) {
22
23 var transaction = new StellarSdk.TransactionBuilder(account)
24
25 .addOperation(StellarSdk.Operation.createAccount({
26 destination: newKeyPair.publicKey(),
27 startingBalance: '5',
28 }))
29 .build();
30
31 transaction.sign(sourceKeyPair);
32
33 server.submitTransaction(transaction)
34 .then(function(transactionResult) {
35 console.log(JSON.stringify(transaction, null, 2));
36 })
37 .catch(function(err) {
38 console.log('An error has occured:');
39 console.log(err);
40 });
41 })
42 .catch(function(err) {
43 console.error(err);
44 })
45
46})