diff --git a/_code-samples/modular-tutorials/account-support.js b/_code-samples/modular-tutorials/account-support.js
index 8e237c04def..e3be2c93dcb 100644
--- a/_code-samples/modular-tutorials/account-support.js
+++ b/_code-samples/modular-tutorials/account-support.js
@@ -206,3 +206,14 @@ async function getTokenBalance() {
}
} // End of getTokenBalance()
+// *******************************************************
+// **************** Scroll Results ***********************
+// *******************************************************
+let results
+
+async function updateResults() {
+ resultField.value += results;
+ resultField.scrollTop = resultField.scrollHeight;
+}
+
+// End of updateResults()
\ No newline at end of file
diff --git a/_code-samples/modular-tutorials/create-permissioned-domain.html b/_code-samples/modular-tutorials/create-permissioned-domain.html
new file mode 100644
index 00000000000..f05d4901236
--- /dev/null
+++ b/_code-samples/modular-tutorials/create-permissioned-domain.html
@@ -0,0 +1,211 @@
+
+
+ Create Permissioned Domain
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create Permissioned Domain
+
+
+
+
\ No newline at end of file
diff --git a/_code-samples/modular-tutorials/credential-manager.js b/_code-samples/modular-tutorials/credential-manager.js
new file mode 100644
index 00000000000..a9f18e27edf
--- /dev/null
+++ b/_code-samples/modular-tutorials/credential-manager.js
@@ -0,0 +1,64 @@
+// Create credential function
+async function createCredential() {
+
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ results = `\n\n===Creating Credential===\n\nConnecting to ${getNet()} ...`
+ updateResults()
+ await client.connect()
+ results = `\n\nConnected.`
+ updateResults()
+
+ // Gather transaction info
+ try {
+
+ // Get account wallet from seed
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+
+ // Get subject
+ const subject = subjectField.value
+
+ // Get credential type - convert string to hex if needed
+ let credentialType = credentialTypeField.value;
+ if (!/^[0-9A-F]+$/i.test(credentialType)) {
+ let hex = '';
+ for (let i = 0; i < credentialType.length; i++) {
+ const charCode = credentialType.charCodeAt(i);
+ const hexCharCode = charCode.toString(16).padStart(2, '0');
+ hex += hexCharCode;
+ }
+ credentialType = hex.toUpperCase();
+ }
+
+ // Prepare transaction
+ const transaction = {
+ "TransactionType": "CredentialCreate",
+ "Account": wallet.address,
+ "Subject": subject,
+ "CredentialType": credentialType
+ }
+
+ results = `\n\n===Preparing and Sending Transaction===\n\n${JSON.stringify(transaction, null, 2)}`
+ updateResults()
+
+ // Submit transaction
+ const tx = await client.submitAndWait(transaction, {autofill: true, wallet: wallet})
+
+ if (tx.result.meta.TransactionResult == "tesSUCCESS") {
+ // Parse for credential info
+ const parsedResponse = JSON.parse(JSON.stringify(tx.result.meta.AffectedNodes, null, 2))
+ const credentialInfo = parsedResponse.find( node => node.CreatedNode && node.CreatedNode.LedgerEntryType === "Credential" )
+ results = `\n\n===Create Credential Result===\n\n${JSON.stringify(credentialInfo.CreatedNode, null, 2)}`
+ } else {
+ results = `\n\n===Error===\n\n${JSON.stringify(tx.result.meta.TransactionResult, null, 2)}: Check codes at https://xrpl.org/docs/references/protocol/transactions/types/credentialcreate#error-cases`
+ }
+
+ updateResults()
+
+ } catch (error) {
+ results = `\n\n===Error===\n\n${error}`
+ updateResults()
+ }
+
+ client.disconnect()
+}
diff --git a/_code-samples/modular-tutorials/permissioned-domain-manager.js b/_code-samples/modular-tutorials/permissioned-domain-manager.js
new file mode 100644
index 00000000000..71a2b9086d6
--- /dev/null
+++ b/_code-samples/modular-tutorials/permissioned-domain-manager.js
@@ -0,0 +1,127 @@
+/// Create permissioned domain
+async function createDomain() {
+
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ results = `\n\n===Creating Permissioned Domain===\n\nConnecting to ${getNet()} ...`
+ updateResults()
+ await client.connect()
+ results = `\n\nConnected.`
+ updateResults()
+
+ // Gather transaction info
+ try {
+
+ // Get account wallet from seed
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+
+ // Get Domain ID
+ const domainID = domainIDField.value
+
+ // Get credential type - convert string to hex if needed
+ let credentialType = credentialTypeField.value;
+ if (!/^[0-9A-F]+$/i.test(credentialType)) {
+ let hex = '';
+ for (let i = 0; i < credentialType.length; i++) {
+ const charCode = credentialType.charCodeAt(i);
+ const hexCharCode = charCode.toString(16).padStart(2, '0');
+ hex += hexCharCode;
+ }
+ credentialType = hex.toUpperCase();
+ }
+
+ // Prepare transaction
+ const transaction = {
+ "TransactionType": "PermissionedDomainSet",
+ "Account": wallet.address,
+ "AcceptedCredentials": [
+ {
+ "Credential": {
+ "Issuer": wallet.address,
+ "CredentialType": credentialType
+ }
+ }
+ ]
+ }
+
+ if (domainID) {
+ transaction.DomainID = domainID
+ }
+
+ results = `\n\n===Preparing and Sending Transaction===\n\n${JSON.stringify(transaction, null, 2)}`
+ updateResults()
+
+ // Submit transaction
+ const tx = await client.submitAndWait(transaction, {autofill: true, wallet: wallet})
+
+ if (tx.result.meta.TransactionResult == "tesSUCCESS") {
+ // Parse for domain info
+ if (domainID) {
+ results = `\n\n===Create Permissioned Domain Result===\n\n${JSON.stringify(tx.result.tx_json, null, 2)}`
+ } else {
+ const parsedResponse = JSON.parse(JSON.stringify(tx.result.meta.AffectedNodes, null, 2))
+ const domainInfo = parsedResponse.find( node => node.CreatedNode && node.CreatedNode.LedgerEntryType === "PermissionedDomain" )
+ results = `\n\n===Create Permissioned Domain Result===\n\n${JSON.stringify(domainInfo.CreatedNode, null, 2)}`
+ }
+ } else {
+ results = `\n\n===Error===\n\n${JSON.stringify(tx.result.meta.TransactionResult, null, 2)}: Check codes at https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomainset#error-cases`
+ }
+ updateResults()
+
+ } catch (error) {
+ results = `\n\n===Error===\n\n${error}`
+ updateResults()
+ }
+
+ client.disconnect()
+}
+// End create permissioned domain
+
+
+// Delete permissioned domain
+async function deleteDomain() {
+
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ results = `\n\n===Delete Permissioned Domain===\n\nConnecting to ${getNet()} ...`
+ updateResults()
+ await client.connect()
+ results = `\n\nConnected.`
+ updateResults()
+
+ // Get delete domain transaction info
+ try {
+
+ // Get account wallet from seed
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+
+ // Get Domain ID
+ const domainID = domainIDField.value
+
+ // Prepare transaction
+ const transaction = {
+ "TransactionType": "PermissionedDomainDelete",
+ "Account": wallet.address,
+ "DomainID": domainID
+ }
+
+ results = `\n\n===Preparing and Sending Transaction===\n\n${JSON.stringify(transaction, null, 2)}`
+ updateResults()
+
+ // Submit delete domain transaction
+ const tx = await client.submitAndWait(transaction, {autofill: true, wallet: wallet})
+
+ if (tx.result.meta.TransactionResult == "tesSUCCESS") {
+ results = `\n\n===Delete Permissioned Domain Result===\n\nSuccessfully deleted the permissioned domain.`
+ } else {
+ results = `\n\n===Error===\n\n${JSON.stringify(tx.result.meta.TransactionResult, null, 2)}: Check codes at https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomaindelete#error-cases`
+ }
+ updateResults()
+
+ } catch (error) {
+ results = `\n\n===Error===\n\n${error}`
+ updateResults()
+ }
+
+ client.disconnect()
+}
diff --git a/docs/img/create-permissioned-domain-1.png b/docs/img/create-permissioned-domain-1.png
new file mode 100644
index 00000000000..6c46495f684
Binary files /dev/null and b/docs/img/create-permissioned-domain-1.png differ
diff --git a/docs/img/create-permissioned-domain-2.png b/docs/img/create-permissioned-domain-2.png
new file mode 100644
index 00000000000..fef092cf7bb
Binary files /dev/null and b/docs/img/create-permissioned-domain-2.png differ
diff --git a/docs/img/create-permissioned-domain-3.png b/docs/img/create-permissioned-domain-3.png
new file mode 100644
index 00000000000..271bbd535ff
Binary files /dev/null and b/docs/img/create-permissioned-domain-3.png differ
diff --git a/docs/img/create-permissioned-domain-4.png b/docs/img/create-permissioned-domain-4.png
new file mode 100644
index 00000000000..dd9212b4168
Binary files /dev/null and b/docs/img/create-permissioned-domain-4.png differ
diff --git a/docs/img/create-permissioned-domain-5.png b/docs/img/create-permissioned-domain-5.png
new file mode 100644
index 00000000000..9e877ebf7d4
Binary files /dev/null and b/docs/img/create-permissioned-domain-5.png differ
diff --git a/docs/tutorials/javascript/compliance/create-permissioned-domains.md b/docs/tutorials/javascript/compliance/create-permissioned-domains.md
new file mode 100644
index 00000000000..47ebb6816f7
--- /dev/null
+++ b/docs/tutorials/javascript/compliance/create-permissioned-domains.md
@@ -0,0 +1,124 @@
+---
+seo:
+ description: Create a permissioned domain to restrict access to financial services that meet compliance requirements.
+labels:
+ - Decentralized Finance
+ - Permissioned Domains
+---
+# Create Permissioned Domains
+
+Permissioned domains are controlled environments within the broader ecosystem of the XRP Ledger blockchain. Domains restrict access to other features such as Permissioned DEXes and Lending Protocols, only allowing access to them for accounts with specific credentials.
+
+This example shows how to:
+
+1. Issue a credential to an account.
+2. Create a permissioned domain with the issued credential.
+3. Delete the permissioned domain.
+
+[](/docs/img/create-permissioned-domain-1.png)
+
+Download the [Modular Tutorials](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/modular-tutorials/) folder.
+
+{% admonition type="info" name="Note" %}
+Without the Modular Tutorial Samples, you will not be able to try the examples that follow.
+{% /admonition %}
+
+## Get Accounts
+
+To get test accounts:
+
+1. Open `create-permissioned-domains.html` in a browser.
+2. Get test accounts.
+ - If you copied the gathered information from another tutorial:
+ 1. Paste the gathered information to the **Result** field.
+ 2. Click **Distribute Account Info**.
+ - If you have an existing account seed:
+ 1. Paste the account seed to the **Account 1 Seed** or **Account 2 Seed** field.
+ 2. Click **Get Account 1 from Seed** or **Get Account 2 from Seed**.
+ - If you do not have existing accounts:
+ 1. Click **Get New Account 1**.
+ 2. Click **Get New Account 2**.
+
+[](/docs/img/create-permissioned-domain-2.png)
+
+
+## Issue a Credential
+
+1. Click the **Account 1** radial button. This account will be the credential issuer.
+2. Copy the account 2 address into **Subject**.
+3. Enter a **Credential Type**. For example, _KYC_.
+4. Click **Create Credential**.
+
+[](/docs/img/create-permissioned-domain-3.png)
+
+
+## Create a Permissioned Domain
+
+1. Click **Create Permissioned Domain**.
+2. Copy the _LedgerIndex_ value from the metadata response.
+3. (Optional) Update the permissioned domain with a different credential.
+ 1. Change the **Credential Type**.
+ 2. Click **Create Credential**.
+ 3. Copy the _LedgerIndex_ value into **DomainID**.
+ 4. Click **Create Permissioned Domain**.
+
+[](/docs/img/create-permissioned-domain-4.png)
+
+
+## Delete a Permissioned Domain
+
+1. Copy the _LedgerIndex_ value into **DomainID**.
+2. Click **Delete Permissioned Domain**.
+
+[](/docs/img/create-permissioned-domain-5.png)
+
+
+
+# Code Walkthrough
+
+## credential-manager.js
+
+### Create Credential
+
+Define a function that issues a credential to a subject and connects to the XRP Ledger.
+
+{% code-snippet file="/_code-samples/modular-tutorials/credential-manager.js" language="js" from="// Create credential function" before="// Gather transaction info" /%}
+
+Gather the issuer information, subject, and credential type. Convert the credential type value to a hex string if not already in hex. Wrap the code in a `try-catch` block to handle errors.
+
+{% code-snippet file="/_code-samples/modular-tutorials/credential-manager.js" language="js" from="// Gather transaction info" before="// Submit transaction" /%}
+
+Submit the `CredentialCreate` transaction and report the results. Parse the metadata response to return only relevant credential info.
+
+{% code-snippet file="/_code-samples/modular-tutorials/credential-manager.js" language="js" from="// Submit transaction" /%}
+
+
+## permissioned-domain-manager.js
+
+### Create Permissioned Domain
+
+Define a function that creates a permissioned domain and connects to the XRP Ledger.
+
+{% code-snippet file="/_code-samples/modular-tutorials/permissioned-domain-manager.js" language="js" from="/// Create permissioned domain" before="// Gather transaction info" /%}
+
+Gather issuer information, credential type, and domain ID. Format the transaction depending on if the optional domain ID field is included. Wrap the code in a `try-catch` block to handle errors.
+
+{% code-snippet file="/_code-samples/modular-tutorials/permissioned-domain-manager.js" language="js" from="// Gather transaction info" before="// Submit transaction" /%}
+
+Submit the `PermissionedDomainSet` transaction and report the results. The metadata is formed differently if a domain ID is included; parse the response accordingly.
+
+{% code-snippet file="/_code-samples/modular-tutorials/permissioned-domain-manager.js" language="js" from="// Submit transaction" before="// End create permissioned domain" /%}
+
+### Delete Permissioned Domain
+
+Define a function to delete a permissioned domain and connect to the XRP Ledger.
+
+{% code-snippet file="/_code-samples/modular-tutorials/permissioned-domain-manager.js" language="js" from="// Delete permissioned domain" before="// Get delete domain transaction info" /%}
+
+Gather account information and domain ID values. Wrap the code in a `try-catch` block to handle errors.
+
+{% code-snippet file="/_code-samples/modular-tutorials/permissioned-domain-manager.js" language="js" from="// Get delete domain transaction info" before="// Submit delete domain transaction" /%}
+
+Submit the `PermissionedDomainDelete` transaction and report the results.
+
+{% code-snippet file="/_code-samples/modular-tutorials/permissioned-domain-manager.js" language="js" from="// Submit delete domain transaction" /%}
diff --git a/sidebars.yaml b/sidebars.yaml
index 209a20bea71..91d565bff80 100644
--- a/sidebars.yaml
+++ b/sidebars.yaml
@@ -214,6 +214,7 @@
- page: docs/tutorials/javascript/build-apps/credential-issuing-service.md
- page: docs/tutorials/javascript/compliance/index.md
items:
+ - page: docs/tutorials/javascript/compliance/create-permissioned-domains.md
- page: docs/tutorials/javascript/compliance/verify-credential.md
- page: docs/tutorials/python/index.md
expanded: false