Last active
April 18, 2017 23:05
-
-
Save wilsonianb/2000c1a4f142f93198d090375ee29ed7 to your computer and use it in GitHub Desktop.
Sign and submit EscrowCreate Ripple transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ npm install ripple-lib | |
// $ RIPPLE_SECRET=sECRET RIPPLE_ADDRESS=rADDRESS XRP_AMOUNT=1 EXPIRATION=2017-04-19T00:00:00Z RIPPLE_SERVER="ws://s.altnet.rippletest.net:51233" node escrow-create.js | |
// For main network, use RIPPLE_SERVER="wss://s1.ripple.com:443" | |
var ripple = require('ripple-lib') | |
const ADDRESS = process.env['RIPPLE_ADDRESS'] | |
const SECRET = process.env['RIPPLE_SECRET'] | |
const DEST = process.env['DESTINATION_ADDRESS'] | |
const AMOUNT = process.env['XRP_AMOUNT'] | |
const EXPIRATION = process.env['EXPIRATION'] | |
const IP = process.env['RIPPLE_SERVER'] | |
const api = new ripple.RippleAPI({server: IP}); | |
api.connect().then(() => { | |
return api.prepareEscrowCreation(ADDRESS, { | |
amount: AMOUNT, | |
destination: DEST ? DEST : ADDRESS, | |
allowCancelAfter: EXPIRATION | |
}).then(prepared => { | |
console.log(prepared) | |
const signedTransaction = api.sign(prepared.txJSON, SECRET).signedTransaction; | |
return api.submit(signedTransaction); | |
}) | |
.then(result => { | |
console.log(result) | |
process.exit(0); | |
}) | |
}).catch(error => { | |
console.log(error) | |
process.exit(1); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment