Getting Addresses & Public Keys

After establishing a connection, you'll likely need to know the user's BSV and 1Sat Ordinal addresses at some point.

A single request can handle gathering all addresses.

🔒 The identityAddress should be used if you are planning to lock coins.

const wallet = initProvider(); // see "Detecting the Provider"
try {
    const { bsvAddress, ordAddress, identityAddress } = await wallet.getAddresses();
    console.log(bsvAddress);
    console.log(ordAddress);
    console.log(identityAddress);
    // 18RPcXk3mMohGpit2XfUYxdz38VVhCZWNC
    // 1GR5sLCMRyXZALFEXDkE8Mc9vJ5gWbDLYF
    // 16uE6Bo2z3gcyMEvsUc66q6QfMgRGyseGV
} catch (err) {
    console.log(err);
}

Although the identityPubKey is provided on a successful connection, if you need to request additional public keys you can do so very easily.

try {
    const { bsvPubKey, ordPubKey, identityPubKey } = await wallet.getPubKeys();
    console.log(bsvPubKey);
    console.log(ordPubKey);
    console.log(identityPubKey);
    // 03c04949f993b0185b4dc10a0876be5b3292e55cbb60d5ea4bb6702f69c7240747
    // 035077b656031c6e197e611c34f83970e5f304ccfce68d4264f34ae1e33d14e8ee
    // 03d8111d4717b15c4b4204e429d46b32d84b2976576c2574d836b41d709f07e1b8
} catch (err) {
    console.log(err);
}

Last updated