Delegate Permissions (JavaScript) Sample Code
These code samples demonstrate how to delegate permissions to another account and how to send an a transaction as a delegate, using xrpl.js 4.3 in Node.js.
Usage
-
First, install dependencies.
npm i -
Go to the XRP Faucet and generate a Devnet account to be your delegate account.
-
Edit
delegate-permisions.jsand change the following line to use the address you got from the faucet:const delegate_address = "r9GAKojMTyexqvy8DXFWYq63Mod5k5wnkT" -
Run
delegate-permissions.js.node delegate-permissions.jsIf it runs successfully, it should output several things including "Delegate successfully set." followed by an account_objects API method response showing the delegate permissions.
Take note of the
accountaddress in this output. That's the address of the delegating account. -
Run
use-delegate-permissions.jsand provide both the delegating account's address (from the previous step's output) and the delegate's secret key (from the devnet faucet earlier).If it runs successfully, it should output various things ending in the following:
Transaction successful. Domain is example.com