A library to make it easier to write your own Stellar wallets.
It provides straightforward APIs for handling these tasks:
- Fetching and formatting data from the Stellar network
- Encrypting and storing secret keys
- Transferring funds to and from the Stellar network
Some things the library will try to do well:
- Useful type definitions
- Consistent, descriptive names
- Do rote tasks automatically for the user
- Provide one obvious, streamlined way of accomplishing each task
This is not an attempt to replace
stellar-sdk, it's meant to provide a better
API in some areas (data-fetching, transfers) and new functionality in others
Fetching and formatting data
Our library's goal is to provide typed, consistently-named Stellar data through a consistent, predictable API.
Note that our goal was to name data properties to be internally consistent and intuitive, not to be perfectly consistent with Horizon's responses. In some cases (particularly around offer / trade history), properties were renamed for clarity.
;// You'll use your DataProvider instance to ask for data from Stellar.const dataProvider =serverUrl: ""accountOrKey: "<<Insert public key>>";// Some class functions will fetch data directly.const offers = await dataProvider;// Others will watch the network for changes and invoke callback when it happens.dataProvider;
Encrypting and storing secret keys
Our KeyManager class allows you to securely encrypt keys client-side so you're never sending sensitive information (the user's key or password) over the wire in a raw state.
;// To instantiate a keyManager instance, pass it an object that conforms to// the KeyStore interface.const keyManager =// The library comes with a sample KeyStore that stores keys in memory.keyStore:;// Then, you need to register an encrypter to handle encrypting / decrypting keys.// The library comes with two samples. (Don't use the Identity Encrypter in prod!)keyManager;// If you're writing a production wallet, you'll probably want to write your own// KeyStore and/or Encrypter. Make sure they conform to the `KeyStore` and// `Encrypter` interfaces defined in these docs. You can use the `PluginTesting`// functions to make sure that your plugins meet spec!thisstatekeyManager;
Like the rest of the
Transfers API is meant to
provide a predictable, easy-to-use interface.
;const withdrawProvider = "<<Insert transfer server URL>>";const supportedAssets = await withdrawProvider;console;const fee = await withdrawProvider;console;const withdrawResult = await withdrawProvider;