1inch
AI-generatedOverview
This n8n node enables users to perform token swaps on various blockchain networks using the 1inch protocol. It facilitates swapping a specified amount of one token for another by interacting with the 1inch API and sending transactions through a user-specified RPC endpoint. This node is particularly useful for automating DeFi workflows, such as portfolio rebalancing, arbitrage strategies, or automated trading across multiple blockchains.
Practical examples:
- Automatically swap USDT for DAI on Arbitrum when certain market conditions are met.
- Rebalance assets between Ethereum and Polygon by swapping tokens via 1inch.
- Integrate with other n8n nodes to trigger swaps based on external signals (e.g., price alerts).
Properties
| Name | Meaning |
|---|---|
| Chain | The blockchain network to use for the swap. Options: Ethereum, Binance Smart Chain, Polygon, Optimism, Arbitrum, Gnosis Chain, Avalanche, Fantom, Klaytn, Aurora. |
| RPC Address | The RPC endpoint used to send the transaction. |
| Input Token Address | The contract address of the token you want to swap from. |
| Output Token Address | The contract address of the token you want to receive. |
| Input Token Amount | The amount of the input token to swap. Note: Pay attention to token decimals. |
| Slippage | Allowed slippage percentage for the swap (min: 0; max: 50). |
Output
The node outputs an array of JSON objects, each containing details about the executed swap transaction:
[
{
"hash": "string", // Transaction hash
"to": "string", // Recipient address
"from": "string", // Sender address
"nonce": number, // Transaction nonce
"gasLimit": string, // Gas limit for the transaction
"value": string, // Value sent in the transaction (in wei)
"chainId": number // ID of the blockchain network
}
]
- No binary data is output by this node.
Dependencies
- External Service: Requires access to the 1inch API for performing swaps.
- API Key / Credentials: Needs a wallet private key provided via n8n credentials named
walletApi. - RPC Endpoint: A valid RPC URL for the selected blockchain network.
- n8n Configuration: Ensure that the
walletApicredential is securely configured in your n8n instance.
Troubleshooting
Common Issues:
- Invalid Private Key: If the
walletApicredential is missing or incorrect, the node will fail to sign and send transactions. - Incorrect RPC Address: Using an invalid or non-responsive RPC endpoint will result in connection errors or failed transactions.
- Insufficient Funds: If the wallet does not have enough balance to cover the swap and gas fees, the transaction will fail.
- Slippage Too Low/High: Setting slippage outside the allowed range (0–50) may cause validation errors or failed swaps.
Error Messages & Resolutions:
- "Invalid chainId or RPC address" – Double-check the selected chain and ensure the RPC endpoint matches the network.
- "Transaction failed due to insufficient funds" – Fund the wallet with enough native currency for gas and the input token for the swap.
- "Swap failed: slippage too low" – Increase the slippage tolerance if swaps are failing due to price movement.
Links and References
- 1inch Documentation
- n8n Credentials Documentation
- Ethereum RPC Endpoints
- Token Contract Addresses (for Ethereum mainnet)