Create a quote
A quote is a commitment from an account servicing entity to deliver a particular amount to a payee when sending a particular amount from a payer. Once an authorized client obtains the requisite grant from the payer’s authorization server, the client can create a quote resource against the payer’s wallet address. The quote indicates how much it will cost the payer to proceed with the transaction.
Before you begin
We recommend creating a wallet account on Rafiki.Money, a test wallet provider that’s part of the Interledger testnet. Creating an account allows you to test your client against the Open Payments API using an ILP-enabled wallet funded with play money.
Create a quote with an incomingAmount
This code snippet allows a client to create a quote with an incomingAmount
when it is specified in the INCOMING_PAYMENT_URL
.
- Node 18
- A package manager such as NPM or PNPM
-
Open Payments SDK
- TSX
Additional configuration
Add "type": "module"
to package.json
Add the following to tsconfig.json
Get started
Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
Create quote
const quote = await client.quote.create(
{
url: new URL(WALLET_ADDRESS).origin,
accessToken: QUOTE_ACCESS_TOKEN,
},
{
method: "ilp",
walletAddress: WALLET_ADDRESS,
receiver: INCOMING_PAYMENT_URL,
},
);
Output
console.log("QUOTE_URL =", quote.id);
Run tsx path/to/directory/index.ts
.
- Node 18 or higher
- A package manager such as NPM or PNPM
-
Open Payments SDK
Additional configuration
Add "type": "module"
to package.json
Get started
Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
Create quote
const quote = await client.quote.create(
{
url: new URL(WALLET_ADDRESS).origin,
accessToken: QUOTE_ACCESS_TOKEN,
},
{
method: "ilp",
walletAddress: WALLET_ADDRESS,
receiver: INCOMING_PAYMENT_URL,
},
);
Output
console.log("QUOTE_URL =", quote.id);
Run node path/to/directory/index.js
.
Create a quote with a debit amount
This code snippet allows a client to create a quote with a debitAmount
, which specifies the amount that will be deducted from the payer’s wallet.
- Node 18
- A package manager such as NPM or PNPM
-
Open Payments SDK
- TSX
Additional configuration
Add "type": "module"
to package.json
Add the following to tsconfig.json
Get started
Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
Get wallet address information
const walletAddress = await client.walletAddress.get({
url: WALLET_ADDRESS,
});
Create quote with debit amount
const quote = await client.quote.create(
{
url: new URL(WALLET_ADDRESS).origin,
accessToken: QUOTE_ACCESS_TOKEN,
},
{
method: "ilp",
walletAddress: WALLET_ADDRESS,
receiver: INCOMING_PAYMENT_URL,
debitAmount: {
value: "500",
assetCode: walletAddress.assetCode,
assetScale: walletAddress.assetScale,
},
},
);
Output
console.log("QUOTE_URL =", quote.id);
Run tsx path/to/directory/index.ts
.
- Node 18 or higher
- A package manager such as NPM or PNPM
-
Open Payments SDK
Additional configuration
Add "type": "module"
to package.json
Get started
Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
Get wallet address information
const walletAddress = await client.walletAddress.get({
url: WALLET_ADDRESS,
});
Create quote with debit amount
const quote = await client.quote.create(
{
url: new URL(WALLET_ADDRESS).origin,
accessToken: QUOTE_ACCESS_TOKEN,
},
{
method: "ilp",
walletAddress: WALLET_ADDRESS,
receiver: INCOMING_PAYMENT_URL,
debitAmount: {
value: "500",
assetCode: walletAddress.assetCode,
assetScale: walletAddress.assetScale,
},
},
);
Output
console.log("QUOTE_URL =", quote.id);
Run node path/to/directory/index.js
.
Create a quote with a receive amount
This code snippet allows a client to create a quote with a receiveAmount
, which specifies the amount that the payee’s wallet will receive.
- Node 18
- A package manager such as NPM or PNPM
-
Open Payments SDK
- TSX
Additional configuration
Add "type": "module"
to package.json
Add the following to tsconfig.json
Get started
Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
Get wallet address information
const walletAddress = await client.walletAddress.get({
url: WALLET_ADDRESS,
});
Create quote with receive amount
const quote = await client.quote.create(
{
url: new URL(WALLET_ADDRESS).origin,
accessToken: QUOTE_ACCESS_TOKEN,
},
{
method: "ilp",
walletAddress: WALLET_ADDRESS,
receiver: INCOMING_PAYMENT_URL,
receiveAmount: {
value: "500",
assetCode: walletAddress.assetCode,
assetScale: walletAddress.assetScale,
},
},
);
Output
console.log("QUOTE_URL =", quote.id);
Run tsx path/to/directory/index.ts
.
- Node 18 or higher
- A package manager such as NPM or PNPM
-
Open Payments SDK
Additional configuration
Add "type": "module"
to package.json
Get started
Import dependencies
import { createAuthenticatedClient } from "@interledger/open-payments";
Initialize Open Payments client
const client = await createAuthenticatedClient({
walletAddressUrl: WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID,
});
Get wallet address information
const walletAddress = await client.walletAddress.get({
url: WALLET_ADDRESS,
});
Create quote with receive amount
const quote = await client.quote.create(
{
url: new URL(WALLET_ADDRESS).origin,
accessToken: QUOTE_ACCESS_TOKEN,
},
{
method: "ilp",
walletAddress: WALLET_ADDRESS,
receiver: INCOMING_PAYMENT_URL,
receiveAmount: {
value: "500",
assetCode: walletAddress.assetCode,
assetScale: walletAddress.assetScale,
},
},
);
Output
console.log("QUOTE_URL =", quote.id);
Run node path/to/directory/index.js
.