Jump to content

Ripple API Offline Wallet/Address Creation


gp94

Recommended Posts

Hi,

New to this forum, not sure if this is the right place to post but wasn't able to post in other sub forums.

I have created an offline Linux Ubuntu environment running nodejs. 

I was hoping if someone could please verify my code/steps and provide further guidance. 

So far I have been able to generate a secret and address using the below code.:

const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI();
console.log(api.generateAddress());

Which returns the following output:

{ secret: 's****************************',
  address: 'r*********************************' }

Then I have created a payment using the following code:

const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI();
const address = 'r9********************************';
const secret = 's****************************';

const payment = {
  "source": {
    "address": "r9********************************",
    "maxAmount": {
      "value": "50",
      "currency": "XRP",
    }
  },
  "destination": {
    "address": "rp********************************",
    "amount": {
      "value": "50",
      "currency": "XRP",
    }
  }
};

const instructions = {
fee: '0.000032',
sequence: 98866,
maxLedgerVersion: 25670000
};

//api.connect().then(() => {
return api.preparePayment(address, payment, instructions).then(prepared => {
console.log(prepared);
console.log(prepared.txJSON);
const {signedTransaction} = api.sign(prepared.txJSON, secret);
console.log(signedTransaction);
const {id} = api.sign(prepared.txJSON, secret);
console.log(id);

});

Which outputs the following incl. tx blob?

{ txJSON: '{"TransactionType":"Payment","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Destination":"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo","Amount":"50000000","Flags":2147483648,"LastLedgerSequence":25670000,"Fee":"32","Sequence":98866}',
  instructions: { fee: '0.000032', sequence: 98866, maxLedgerVersion: 25670000 } }
{"TransactionType":"Payment","Account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59","Destination":"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo","Amount":"50000000","Flags":2147483648,"LastLedgerSequence":25670000,"Fee":"32","Sequence":98866}
12000022800000002400018232201B0187B170614000000002FAF080684000000000000020732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402200EBD74BA4068D2C51F9876703E8E44DAD6428E553C82387904FD927A393D8BA902201389A1CADDD8414D392CFC659FAAA9337873C7968DDF59EB32BFA0387FC7D27381145E7B112523F68D2F5E879DB4EAC51C6698A6930483141122F763E965DF2280CDAD599C9CFF875F727BC4
74928B7F9C87504A1786B75F90D6772DBDBAA985E22292EFF255F8B08239FB77

 

Would really appreciate if someone could please review the above and let me know if it is correct and if anything should be changed, and also what is the next step easiest way to take this tx blob and submit it online somewhere to process the transaction?

Thanks in advance. 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...