Migrate set-global-freeze.js

This commit is contained in:
Jackson Mills
2021-10-15 10:55:31 -07:00
parent 04b075d490
commit 884607cb2e

View File

@@ -1,37 +1,29 @@
const {RippleAPI} = require('ripple-lib'); const xrpl = require('xrpl')
const api = new RippleAPI({ async function main() {
server: 'wss://s1.ripple.com' // Public rippled server // Connect -------------------------------------------------------------------
}); const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
api.on('error', (errorCode, errorMessage) => { await client.connect()
client.on('error', (errorCode, errorMessage) => {
console.log(errorCode + ': ' + errorMessage); console.log(errorCode + ': ' + errorMessage);
}); });
const issuing_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'; const { wallet, balance } = await client.fundWallet()
const issuing_secret = 's████████████████████████████';
// Best practice: get your secret from an encrypted
// config file instead
api.connect().then(() => {
// Prepare a settings transaction to enable global freeze // Prepare a settings transaction to enable global freeze
const settings = { const accountSetTx = {
'globalFreeze': true TransactionType: "AccountSet",
Account: wallet.address,
SetFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze
}; };
console.log('preparing settings transaction for account:',
issuing_address);
return api.prepareSettings(issuing_address, settings);
}).then(prepared_tx => {
// Sign and submit the settings transaction // Sign and submit the settings transaction
console.log('signing tx:', prepared_tx.txJSON); console.log('Sign and submit the transaction:', accountSetTx);
const signed1 = api.sign(prepared_tx.txJSON, issuing_secret);
console.log('submitting tx:', signed1.id);
return api.submit(signed1.signedTransaction); await client.submitReliable(wallet, accountSetTx);
}).then(() => { client.disconnect()
return api.disconnect(); }
}).catch(console.error);
main().catch(console.error)