Skip to content

connectWalletClient / connectSigner

The connectWalletClient / connectSigner method connects a wallet client to the Symphony instance for signing transactions.

Signature

connectWalletClient(walletClient: WalletClient): void  // For viem
connectSigner(signer: Signer): void                   // For ethers/ethersV5

TypeScript Types

// Import for viem
import type { WalletClient } from 'viem';
import { Symphony } from 'symphony-sdk/viem';
 
// Import for ethersV5
import type { Signer } from 'ethers';
import { Symphony } from 'symphony-sdk/ethersV5';
 
// Import for ethers v6
import type { Signer } from 'ethers';
import { Symphony } from 'symphony-sdk/ethers';

Parameters

  • walletClient (viem): A WalletClient instance with an account
  • signer (ethers/ethersV5): A Signer instance

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.