mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
Migrate set-global-freeze.js
This commit is contained in:
@@ -1,37 +1,29 @@
|
||||
const {RippleAPI} = require('ripple-lib');
|
||||
const xrpl = require('xrpl')
|
||||
|
||||
const api = new RippleAPI({
|
||||
server: 'wss://s1.ripple.com' // Public rippled server
|
||||
});
|
||||
api.on('error', (errorCode, errorMessage) => {
|
||||
console.log(errorCode + ': ' + errorMessage);
|
||||
});
|
||||
async function main() {
|
||||
// Connect -------------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
const issuing_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
|
||||
const issuing_secret = 's████████████████████████████';
|
||||
// Best practice: get your secret from an encrypted
|
||||
// config file instead
|
||||
client.on('error', (errorCode, errorMessage) => {
|
||||
console.log(errorCode + ': ' + errorMessage);
|
||||
});
|
||||
|
||||
api.connect().then(() => {
|
||||
const { wallet, balance } = await client.fundWallet()
|
||||
|
||||
// Prepare a settings transaction to enable global freeze
|
||||
const settings = {
|
||||
'globalFreeze': true
|
||||
const accountSetTx = {
|
||||
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
|
||||
console.log('signing tx:', prepared_tx.txJSON);
|
||||
const signed1 = api.sign(prepared_tx.txJSON, issuing_secret);
|
||||
console.log('submitting tx:', signed1.id);
|
||||
console.log('Sign and submit the transaction:', accountSetTx);
|
||||
|
||||
return api.submit(signed1.signedTransaction);
|
||||
await client.submitReliable(wallet, accountSetTx);
|
||||
|
||||
}).then(() => {
|
||||
return api.disconnect();
|
||||
}).catch(console.error);
|
||||
client.disconnect()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
Reference in New Issue
Block a user