mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-29 16:15:48 +00:00
Freeze tutorials: fixes and cleanup
- Move JS code samples to JS folder (future-proofing for other languages) - Make "Freeze a Trust Line" tutorial interactive - Add necessary functionality to interactive_tutorial helper JS - Rework freeze a trust line tutorial/code sample to make an incoming line from another address and make looking up trust lines a full-fledged step
This commit is contained in:
39
content/_code-samples/freeze/js/set-no-freeze.js
Normal file
39
content/_code-samples/freeze/js/set-no-freeze.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// Dependencies for Node.js.
|
||||
// In browsers, use <script> tags as in the example demo.html.
|
||||
if (typeof module !== "undefined") {
|
||||
// gotta use var here because const/let are block-scoped to the if statement.
|
||||
var xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Connect -------------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
console.log("Connected to Testnet")
|
||||
|
||||
// Get credentials from the Testnet Faucet ------------------------------------
|
||||
console.log("Requesting an address from the Testnet faucet...")
|
||||
const { wallet, balance } = await client.fundWallet()
|
||||
|
||||
// Submit an AccountSet transaction to enable No Freeze ----------------------
|
||||
const accountSetTx = {
|
||||
TransactionType: "AccountSet",
|
||||
Account: wallet.address,
|
||||
// Set the NoFreeze flag for this account
|
||||
SetFlag: xrpl.AccountSetAsfFlags.asfNoFreeze
|
||||
}
|
||||
|
||||
// Best practice for JS users - validate checks if a transaction is well-formed
|
||||
xrpl.validate(accountSetTx)
|
||||
|
||||
console.log('Sign and submit the transaction:', accountSetTx)
|
||||
await client.submitAndWait(accountSetTx, { wallet: wallet })
|
||||
|
||||
// Done submitting
|
||||
console.log("Finished submitting. Now disconnecting.")
|
||||
await client.disconnect()
|
||||
|
||||
// End main()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
Reference in New Issue
Block a user