---
seo:
description: Issue an asset-backed token such as a US Treasury bill using multi-purpose tokens.
labels:
- Tokens
- MPT
---
# Sending MPTs
_(Requires the [MPToken amendment][] {% not-enabled /%})_
To send an MPT to another account, the receiving account must first authorize the receipt of the MPT, based on its MPToken Issuance ID. This is to prevent malicious users from spamming accounts with unwanted tokens that could negatively impact storage and XRP reserves.
Once an account receives an MPT, it can send the MPT to another account, provided the MPT was created with the _Can Transfer_ flag set, and the receiving account authorizes the MPT.
## Send MPT Utility
The Send MPT utility lets you create an account, authorize it to receive a specific MPT issuance, then send it the authorized MPT from an issuer or holder account. (You can issue an MPT using the [MPT Generator](../../../use-cases/tokenization/creating-an-asset-backed-multi-purpose-token.md) utility.)
[](../../../img/mt-send-mpt-0-empty-form.png)
You can download a [standalone version of the MPT Sender](../../../../_code-samples/mpt-sender/send-mpt.zip) as sample code.
## Get Accounts
To send an MPT, you need the **Seed** value for the MPT issuer to retrieve its account, then you need either a new account or an account seed for the target account. You can use the [MPT Generator](../../../use-cases/tokenization/creating-an-asset-backed-multi-purpose-token.md) to create a new MPT for transfer.
To get the accounts:
1. Open send-mpt.html in a browser.
2. Choose your ledger instance (**Devnet** or **Testnet**).
3. If you used the MPT Generator:
1. Paste the gathered info in the **Result** field.
[](../../../img/mt-send-mpt-1-gathered-info.png)
2. Cut and paste the MPT Issuance ID to the **MPT Issuance ID** field.
3. Click **Distribute Account Info** to populate the **Account 1** fields.
If you did not use the MPT Generator, enter the **Account 1 Name**, **Account 1 Address**, **Account 1 Seed**, and **MPT Issuance ID** in the corresponding fields.)
4. Click **Get New Account 2**, or use a seed to **Get Account 2 from Seed**.
5. Optionally, add the **Account 2 Name**, an arbitrary human-readable name that helps to differentiate the accounts.
[](../../../img/mt-send-mpt-2-account-2.png)
## Authorize MPT
To receive MPTs, an account needs to authorize the MPT.
To authorize Account 2 to accept MPTs:
1. Click the **Account 2** radio button.
2. Enter an **Amount**, the maximum number of MPTs the account will accept.
2. Click **Authorize MPTs**.
[](../../../img/mt-send-mpt-2-authorize-mpt.png)
## Send MPT
To send an MPT:
1. Click the **Account 1** radio button.
3. Enter the **MPT Issuance ID**.
2. Enter an **Amount** of MPTs to send.
3. Enter the **Destination** (likely the value in the **Account 2 Address** field, but it can be any account on the same ledger instance).
4. Click **Send MPT**.
[](../../../img/mt-send-mpt-3-send-mpt.png)
## Get MPTs
To verify receipt of the MPTs:
1. Click the **Account 2** radio button.
2. Click **Get MPTs**.
[](../../../img/mt-send-mpt-4-get-mpts.png)
# Code Walkthrough
You can download a [standalone version of the MPT Sender](../../../../_code-samples/mpt-sender/send-mpt.zip) as sample code.
## send-mpt.js
The code that supports the MPT features is in the `send-mpt.js` file. Standard support for connecting to the XRP Ledger is included in the `account-support.js` file.
### sendMPT()
Connect to the XRP Ledger.
```javascript
async function sendMPT() {
let net = getNet()
const client = new xrpl.Client(net)
await client.connect()
let results = `===Connected to ${net}.===\n===Sending MPT.===\n`
resultField.value = results
```
Instantiate the parameter variables.
```javascript
try {
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
const mpt_issuance_id = mptIdField.value
const mpt_quantity = amountField.value
```
Create a Payment transaction using the MPT for the Amount.
```javascript
const send_mpt_tx = {
"TransactionType": "Payment",
"Account": wallet.address,
"Amount": {
"mpt_issuance_id": mpt_issuance_id,
"value": mpt_quantity,
},
"Destination": destinationField.value,
}
```
Prepare and sign the transaction.
```javascript
const pay_prepared = await client.autofill(send_mpt_tx)
const pay_signed = wallet.sign(pay_prepared)
```
Send the prepared transaction and report the results.
```javascript
results += `\n===Sending ${mpt_quantity} ${mpt_issuance_id} to ${destinationField.value} ...`
resultField.value = results
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
results += '\n\n===Transaction succeeded.\n'
results += JSON.stringify(pay_result.result, null, 2)
resultField.value += results
}
```
Catch and report any errors, then disconnect from the XRP Ledger.
```javascript
catch (error) {
results = `Error sending MPT: ${error}`
resultField.value += results
}
finally {
client.disconnect()
}
} // end of sendMPT()
```
## getMPTs
Get all of the MPTs for the selected account by filtering for MPT objects and looping through the array to display them one at a time.
Connect to the XRPL ledger.
```javascript
async function getMPTs() {
let net = getNet()
const client = new xrpl.Client(net)
await client.connect()
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
let results = ''
resultField.value = `===Connected to ${net}. Getting MPTs.===`
```
Send an `account_objects` request, specifying the type _mptoken_. Wait for the results.
```javascript
try {
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
const mpts = await client.request({
command: "account_objects",
account: wallet.address,
ledger_index: "validated",
type: "mptoken"
})
```
Stringify and parse the JSON result string.
```javascript
let JSONString = JSON.stringify(mpts.result, null, 2)
let JSONParse = JSON.parse(JSONString)
let numberOfMPTs = JSONParse.account_objects.length
```
Loop through the filtered array of account_objects to list all of the MPTs held by the account.
```javascript
let x = 0
while (x < numberOfMPTs){
results += "\n\n===MPT Issuance ID: " + JSONParse.account_objects[x].MPTokenIssuanceID
+ "\n===MPT Amount: " + JSONParse.account_objects[x].MPTAmount
x++
}
```
Return the parsed results, followed by the raw results.
```javascript
results += "\n\n" + JSONString
resultField.value += results
```
Catch and report any errors, then disconnect from the XRP Ledger.
```javascript
} catch (error) {
results = `===Error getting MPTs: ${error}`
resultField.value += results
}
finally {
client.disconnect()
}
} // End of getMPTs()
```
## authorizeMPT
Before you can send an MPT to another account, the target account must authorize the MPT.
Connect to the XRPL and instantiate the account wallet.
```javascript
async function authorizeMPT() {
let net = getNet()
const client = new xrpl.Client(net)
await client.connect()
let results = `Connected to ${net}....`
resultField.value = results
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
```
Capture the MPT issuance ID in a variable.
```javascript
const mpt_issuance_id = mptIdField.value
```
Create the MPTokenAuthorize transaction, passing the target account's address and the MPT Issuance ID.
```javascript
const auth_mpt_tx = {
"TransactionType": "MPTokenAuthorize",
"Account": wallet.address,
"MPTokenIssuanceID": mpt_issuance_id,
}
```
Prepare, sign, and send the transaction.
```javascript
const auth_prepared = await client.autofill(auth_mpt_tx)
const auth_signed = wallet.sign(auth_prepared)
results += `\n\nSending authorization...`
resultField.value = results
const auth_result = await client.submitAndWait(auth_signed.tx_blob)
```
Report the results.
```javascript
if (auth_result.result.meta.TransactionResult == "tesSUCCESS") {
results += `\nTransaction succeeded`
resultField.value = results
} else {
results += `\nTransaction failed: ${auth_result.result.meta.TransactionResult}`
resultField.value = results
}
client.disconnect()
} // end of MPTAuthorize()
```
## send-mpt.html
```html