Build a Wallet interface
Building a Wallet interface is done in two steps:
- Create a
Connector
class - Create a
Wallet
class and use theConnector
class in it
1. Create Connector class
Extend the abstract Connector
interface and implement the all the required methods.
Required methods
Optional methods
You can throw an exception or leave the implementation empty if you don't want to implement these methods.
2. Create Wallet class
Now that the hard part is done, the rest is easy, we just need to wrap our connector in a AbstractClientWallet
class.
The AbstractClientWallet
class is the base
class that provides an interface for interacting with your connector on one side and with applications on the other.
The main method that needs to be overridden is the getConnector
method. This method should return a Promise
that resolves to the Connector
class that you implemented.
You can expose any custom logic here as the public API for your wallet.
Required Methods
Using your new wallet
At this point, you should be able to instantiate your new wallet and call connect
on it.
Examples
You can look at how the built-in wallets in @thirdweb-dev/wallets
package are created for reference