Skip to main content

Overview

Connectors provide the interface between the Fusion SDK and blockchain providers. They handle signing typed data and making contract calls.

BlockchainProviderConnector

Interface that all blockchain provider connectors must implement.
interface BlockchainProviderConnector {
  signTypedData(
    walletAddress: string,
    typedData: EIP712TypedData
  ): Promise<string>

  ethCall(
    contractAddress: string,
    callData: string
  ): Promise<string>
}

Methods

signTypedData
function
required
Sign EIP-712 typed dataParameters:
  • walletAddress (string): The wallet address to sign with
  • typedData (EIP712TypedData): The typed data to sign
Returns: Promise<string> - The signature
ethCall
function
required
Execute an eth_call to read contract stateParameters:
  • contractAddress (string): The contract address to call
  • callData (string): The encoded call data
Returns: Promise<string> - The call result

PrivateKeyProviderConnector

A blockchain provider connector that uses a private key for signing.

Constructor

new PrivateKeyProviderConnector(
  privateKey: string,
  web3Provider: Web3Like
)
privateKey
string
required
The private key to use for signing (with or without 0x prefix)
web3Provider
Web3Like
required
A Web3-like provider for making contract calls

Example

import { PrivateKeyProviderConnector } from '@1inch/fusion-sdk'
import Web3 from 'web3'

const web3 = new Web3('https://eth.llamarpc.com')

const connector = new PrivateKeyProviderConnector(
  'your-private-key',
  web3
)

// Use with FusionSDK
const sdk = new FusionSDK({
  url: 'https://api.1inch.dev/fusion',
  network: NetworkEnum.ETHEREUM,
  blockchainProvider: connector
})

Methods

signTypedData
function
Parameters:
  • walletAddress (string): Not used, signature is created from private key
  • typedData (EIP712TypedData): The typed data to sign
Returns: Promise<string> - The signature
ethCall
function
Parameters:
  • contractAddress (string): The contract address to call
  • callData (string): The encoded call data
Returns: Promise<string> - The call result

Web3ProviderConnector

A blockchain provider connector that uses a Web3 provider’s signing capabilities.

Constructor

new Web3ProviderConnector(web3Provider: Web3Like)
web3Provider
Web3Like
required
A Web3-like provider for signing and making contract calls

Example

import { Web3ProviderConnector } from '@1inch/fusion-sdk'
import Web3 from 'web3'

const web3 = new Web3(window.ethereum)

const connector = new Web3ProviderConnector(web3)

// Use with FusionSDK
const sdk = new FusionSDK({
  url: 'https://api.1inch.dev/fusion',
  network: NetworkEnum.ETHEREUM,
  blockchainProvider: connector
})

Methods

signTypedData
function
Uses eth_signTypedData_v4 RPC methodParameters:
  • walletAddress (string): The wallet address to sign with
  • typedData (EIP712TypedData): The typed data to sign
Returns: Promise<string> - The signature
ethCall
function
Parameters:
  • contractAddress (string): The contract address to call
  • callData (string): The encoded call data
Returns: Promise<string> - The call result

Web3Like Interface

A minimal Web3 provider interface compatible with Web3.js.
interface Web3Like {
  eth: {
    call(transactionConfig: TransactionConfig): Promise<string>
  }
  extend(extension: unknown): any
}
eth.call
function
required
Execute an eth_call to read contract stateParameters:
  • transactionConfig (TransactionConfig): Transaction configuration with to and data fields
Returns: Promise<string> - The call result
extend
function
required
Extend the Web3 instance with custom methodsParameters:
  • extension (unknown): Extension configuration
Returns: any - The extended Web3 instance

TransactionConfig

interface TransactionConfig {
  data?: string
  to?: string
}
data
string
The encoded call data
to
string
The contract address to call

Provider Compatibility

The Web3Like interface is compatible with:
  • Web3.js (v1.x and v4.x)
  • Ethers.js providers (wrapped)
  • MetaMask and other browser wallets
  • Custom RPC providers

See Also

Build docs developers (and LLMs) love