Adapters
An introduction to adapters and how to use them
What is an adapter anyway?
An adapter is a function that takes parameters and returns an object that adheres to this interface. Let’s review the interface in depth:
Property | Description | Required |
---|---|---|
vmType | A string that can either be 'SOL' or 'EVM' | ✅ |
getChainId | An async function that returns a chain id | ✅ |
handleSignMessageStep | An async function that given a signature step item and a step generates a signature | ✅ |
handleSendTransactionStep | An async function that given a chain id, a transaction step item and a step returns a transaction hash | ✅ |
handleConfirmTransactionStep | An async function that given a transaction hash, a chain id, an onReplaced function and an onCancelled function returns a promise with either an evm receipt or an svm receipt | ✅ |
address | An async function that returns the currently connected to address, an address that can sign messages and submit transactions | ✅ |
switchChain | An async function that given a chain id switches to that chain, either by prompting the user or automatically switching chains | ✅ |
transport | An optional transport to use when making rpc calls. | ❌ |
What adapters are available out of the box?
The following adapters are officially maintained and developed by the Reservoir Relay team:
SVM Adapter: This adapter gives the sdk the ability to submit transactions on SVM (Solana Virtual Machine) networks. It does not support signing messages and under the hood it uses the solana web3 sdk.
Viem Adapter: This adapter is the default one used when no adapter is provided. You can also import it yourself to convert any viem wallet client into an adapted wallet ready to be used in the sdk.
Ethers Adapter: If your application uses ethers then you’ll need this adapter to use the SDK. You’ll still need to install viem as that’s required for polling transactions but you can pass in your ethers signer to submit transactions and sign messages.
How can I use an adapter?
You can either make your own adapter, as long as it adheres to the interface above or you can use one of the officials adapters developed and maintained by the Reservoir Relay team. All of our sdk methods handle a viem wallet or adapted wallet. The viem wallet adapter is used by default when a viem wallet is passed in for convenience. Refer below for implementation details: