Disabling the NoRipple Flag | XRPL Development in JavaScript Level 1
In the previous chapter, we introduced the reason why the transaction failed and the relationship between Rippling
and the NoRipple flag
.
To disable Alice’s NoRipple flag
from the issuer’s perspective, let’s change the state using a TrustSet
transaction!
Prerequisites
This guide proceeds with the following characters:
- Charlie (Token Issuer)
- Alice (Token Recipient)
Create the Script
-
Create a new file named
disable_noripple.js
in your project directory. -
Paste the following code into
disable_noripple.js
.So far, we have introduced samples defined as functions, but let’s now create a code pattern with more arguments.
This script disables the NoRipple flag for Alice from Charlie, the issuer.
const xrpl = require('xrpl');async function disableNoRipple(wallet,trustLineCurrency,trustLineIssuer,trustLineLimit) {// Connect to the Testnetconst client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');await client.connect();try {// Create the TrustSet transactionconst trustSetTx = {TransactionType: 'TrustSet',Account: wallet.address, // Issuer's address (Charlie)LimitAmount: {currency: trustLineCurrency, // Currency codeissuer: trustLineIssuer, // User's address (Alice or Bob)value: trustLineLimit, // Limit amount (unchanged here)},// Disable the NoRipple flagFlags: xrpl.TrustSetFlags.tfClearNoRipple,};// Send the transaction and wait for the resultconst response = await client.submitAndWait(trustSetTx, { wallet });console.log('Transaction result:', response);} catch (error) {console.error('An error occurred:', error);}// Disconnectawait client.disconnect();}// Execute the functionconst currency = 'DOJ'; // Currency codeconst trustLineIssuer = 'alice_wallet_address_here'; // User's address (Alice)const limit = '0'; // Limit amount (unchanged here)const issuerWallet = xrpl.Wallet.fromSecret('charlie_wallet_secret_here'); // Issuer's secret key (Charlie)disableNoRipple(issuerWallet, currency, trustLineIssuer, limit); // Change the user's trust line information- Enter Alice’s testnet address in
alice_wallet_address_here
. - Enter Charlie’s testnet secret key in
charlie_wallet_secret_here
.
- Enter Alice’s testnet address in
Run the Script
-
Run the following command in the command line to execute the script.
Terminal window node disable_noripple.js -
If successful, the console will display the following.
Terminal window Transaction result: {id: 12,result: {Account: 'rQr8KfkCQcpqvFwmRspDoaL36reZhcdaeA',Fee: '12',Flags: 262144,LastLedgerSequence: 478802,LimitAmount: {currency: 'DOJ',issuer: 'rh8xETfGs1Ktizj9EXZb5QpW4aqk8bWUSU',value: '20000'},Sequence: 474074,SigningPubKey: 'ED2924DBD08E093DD7FC9C35B8DCEBD74CA4C8349D68D7BF566AD6C2533B8BB865',TransactionType: 'TrustSet',TxnSignature: 'DD350511FDFDB2C430C40CE6CE87B047BAF9130FD98634B8375955BE8863412ED8AB17C3E038D64B2C7805C088258E72861989ECD1280A7B4ABE718669694801',ctid: 'C0074E4000000001',date: 768414741,hash: '97418F46A8B47FFA455DA3A0401BFDF2F09579F9911D64E194768BECB4AC2DC3',inLedger: 478784,ledger_index: 478784,meta: {AffectedNodes: [Array],TransactionIndex: 0,TransactionResult: 'tesSUCCESS' // Success},validated: true},type: 'response'}This successfully disabled the
NoRipple flag
for Alice from the issuer’s perspective.If the sending account’s
NoRipple flag
is disabled, the transfer can be made. In the next chapter, let’s retry theDOJ
token transfer from Alice to Bob that failed in this guide.