Get wallet address information
The Get Wallet Address API lets you get the public information for a wallet address.
A client must verify the validity of a wallet address and get the URL of the wallet’s authorization server before requesting a grant from the server.
The code snippets below let a client verify a wallet address, get the basic information required to construct a new transaction, and discover the auth server’s URL.
Before you begin
Section titled “Before you begin”We recommend creating a wallet account on the test wallet. Creating an account allows you to test your client against the Open Payments APIs by using an ILP-enabled wallet funded with play money.
Retrieve public information for a wallet address
Section titled “Retrieve public information for a wallet address” Prerequisites
// Import dependenciesimport { createAuthenticatedClient } from '@interledger/open-payments'
// Initialize clientconst client = await createAuthenticatedClient({ walletAddressUrl: WALLET_ADDRESS, privateKey: PRIVATE_KEY_PATH, keyId: KEY_ID})
// Get wallet addressconst walletAddress = await client.walletAddress.get({ url: WALLET_ADDRESS})
// Outputconsole.log('WALLET ADDRESS:', walletAddress)For TypeScript, run tsx path/to/directory/index.ts. View full TS source
For JavaScript, run node path/to/directory/index.js. View full JS source
Prerequisites View full source
// Import dependenciesuse open_payments::client::api::UnauthenticatedResources;use open_payments::snippets::utils::{create_unauthenticated_client, get_env_var, load_env};
// Initialize clientlet client = create_unauthenticated_client();
// Get wallet addresslet wallet_address_url = get_env_var("WALLET_ADDRESS_URL")?;let wallet_address = client.wallet_address().get(&wallet_address_url).await?;
// Outputprintln!("Retrieved wallet address: {wallet_address:#?}"); Prerequisites View full source
// Import dependenciesuse OpenPayments\AuthClient;use OpenPayments\Config\Config;
// Initialize client$config = new Config($WALLET_ADDRESS);$opClient = new AuthClient($config); // because of missing keys in config, this will be an unauthenticated client
// Get wallet address$wallet = $opClient->walletAddress()->get(['url' => $config->getWalletAddressUrl()]);
// Outputecho 'WALLET ADDRESS: ' . PHP_EOL . print_r($wallet, true); Prerequisites
package main
// Import dependenciesimport ("context""encoding/json""fmt""log"
op "github.com/interledger/open-payments-go")func main() {// Initialize clientclient, err := op.NewAuthenticatedClient(WALLET_ADDRESS_URL, PRIVATE_KEY_BASE_64, KEY_ID)if err != nil {log.Fatalf("Error creating authenticated client: %v\n", err)}
// Get wallet addresswalletAddress, err := client.WalletAddress.Get(context.TODO(), op.WalletAddressGetParams{URL: WALLET_ADDRESS_URL,})if err != nil {log.Fatalf("Error fetching wallet address: %v\n", err)}
// OutputwalletAddressJSON, err := json.MarshalIndent(walletAddress, "", " ")if err != nil {log.Fatalf("Error marshaling wallet address: %v\n", err)}fmt.Println("WALLET ADDRESS:", string(walletAddressJSON))} Prerequisites
// Import dependenciesimport org.interledger.openpayments.httpclient.OpenPaymentsHttpClient;import org.interledger.openpayments.IOpenPaymentsClient;
// Initialize clientvar client = OpenPaymentsHttpClient.defaultClient("WalletAddress","PrivateKeyPEM","KeyId");
// Get wallet addressvar walletAddress = client.walletAddress().get("https://cloudninebank.example.com/customer");
// Outputlog.info("WALLET_ADDRESS: {}", walletAddress); Prerequisites View full source
// Import dependenciesusing Microsoft.Extensions.DependencyInjection;using Newtonsoft.Json;using OpenPayments.Sdk.Clients;using OpenPayments.Sdk.Extensions;
// Initialize clientvar client = new ServiceCollection() .UseOpenPayments(opts => { opts.UseUnauthenticatedClient = true; }) .BuildServiceProvider() .GetRequiredService<IUnauthenticatedClient>();
// Get wallet address informationvar walletAddress = await client.GetWalletAddressAsync(WALLET_ADDRESS);
// OutputConsole.WriteLine($" WALLET_ADDRESS: {JsonConvert.SerializeObject(walletAddress, Formatting.Indented)}");