Crosschain
Use intents to execute target-chain calls with funds sourced from another chain.
How it works
- Define the calls, target chain, and required tokens.
- The orchestrator prepares a funding route.
- The user approves the intent with a passkey.
- The orchestrator funds and executes it.
Using wagmi
Wagmi provides hooks to integrate crosschain transactions into your React app.
Install the SDK
npm install @rhinestone/1authCreate config.ts
Create a wagmi config file with the 1auth connector. For crosschain transactions, add all the chains you want to support:
config.ts
import { createConfig, http } from 'wagmi'
import { base, mainnet, optimism, arbitrum } from 'wagmi/chains'
import { OneAuthClient } from '@rhinestone/1auth'
import { oneAuth } from '@rhinestone/1auth/wagmi'
// Create the 1auth client
const client = new OneAuthClient({
providerUrl: 'https://passkey.1auth.app',
clientId: 'my-app',
})
// Create the wagmi config with 1auth connector
export const config = createConfig({
chains: [mainnet, base, optimism, arbitrum],
connectors: [oneAuth({ client })],
transports: {
[mainnet.id]: http(),
[base.id]: http(),
[optimism.id]: http(),
[arbitrum.id]: http(),
},
})Build your calls
Each call has a to address, optional data (calldata), and optional value (ETH amount). Calls within this intent execute atomically.
import { encodeFunctionData, parseUnits } from 'viem'
// Example: Approve + Swap in a single atomic batch
const calls = [
{
to: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC contract
data: encodeFunctionData({
abi: erc20Abi,
functionName: 'approve',
args: [DEX_ADDRESS, parseUnits('100', 6)],
}),
},
{
to: DEX_ADDRESS, // DEX contract
data: encodeFunctionData({
abi: dexAbi,
functionName: 'swap',
args: [USDC, WETH, parseUnits('100', 6)],
}),
},
]Send to any chain
Use useSendCalls with your calls array. The key crosschain parameters are:
chainId- specifies which chain the calls execute on (required)tokenRequests- specifies what tokens the user needs for the transaction (optional)
sendCalls({
calls,
chainId: 8453, // Execute on Base
tokenRequests: [{
token: USDC_ADDRESS,
amount: parseUnits('100', 6),
}],
})tokenRequests specifies the tokens required on the target chain; the orchestrator selects a route from the user's available assets.
See Token Requests for the output-first model.
Using the SDK directly
Use sendIntent without wagmi:
import { OneAuthClient } from '@rhinestone/1auth'
import { parseEther } from 'viem'
const client = new OneAuthClient({
providerUrl: 'https://passkey.1auth.app',
clientId: 'my-app',
})
const auth = await client.authenticate()
if (!auth.success) throw new Error(auth.error.message)
const result = await client.sendIntent({
accountAddress: auth.session.accountAddress,
targetChain: 8453, // Base
calls: [
{
to: '0x...', // Contract on Base
data: '0x...', // Calldata
value: parseEther('0.1'),
},
],
closeOn: 'completed',
})
if (result.success) {
console.log('TX Hash:', result.transactionHash)
}Next steps
- Token Requests - Deep dive into the output-first model
- Batch Transactions - Queue multiple transactions with a shopping cart UI
- Fee Sponsorship - Sponsor gas fees for your users