connectWalletClient / connectSigner
The connectWalletClient / connectSigner
method connects a wallet client to the Symphony instance for signing transactions.
Signature
connectWalletClient(walletClient: WalletClient | Signer): void
connectSigner(walletClient: Signer | Signer): void
Parameters
walletClient
: The wallet client to connect- For Viem: A
WalletClient
instance - For Ethers: A
Signer
instance
- For Viem: A
Example Usage
Viem
import { Symphony } from 'symphony-sdk/viem';
import { createWalletClient, custom } from 'viem';
import { sei } from 'viem/chains';
import { getWalletClient } from "@wagmi/core";
const symphony = new Symphony();
// Create wallet client
const walletClient = createWalletClient({
chain: sei,
transport: custom(window.ethereum)
});
// or if you are using wagmi
const walletClient = await getWalletClient(config);
// Get user's address
const [address] = await walletClient.requestAddresses();
walletClient.account = { address };
// Connect wallet client
symphony.connectWalletClient(walletClient);
Notes
- A connected wallet client is required for operations that need signing (e.g., swaps, approvals)
- You can disconnect the wallet client using
disconnectWalletClient
- Only one wallet client can be connected at a time - connecting a new one will replace the existing one
- For viem, walletClient should have a valid account field.