I'm trying to use the data returned from 1inch's Swap API endpoint, to essentially perform a swap from a smart contract instead of from an EOA. The old oneSplit contract provided an easy way to do this, but that's since been deprecated. I'm using ether's to send a transaction object returned from the API like this one. Is it possible to somehow send this transaction in solidity, from a smart contract? (i.e when the contract receives flash loaned assets) Thanks!

"tx": {
    "from": "string",
    "to": "string",
    "data": "string",
    "value": "string",
    "gasPrice": "string",
    "gas": "string"
  • Trying to implement a solifity based solution, similar to how the deprecated oneSplit contract had -getExpectedReturn() and -swap() ethereumdev.io/… Commented May 29, 2022 at 2:14

1 Answer 1


Sure. There are a couple examples in the wild but my favorite example is the swapProxy by smye

To get the data from the API disableEstimate=true is a required parameter. Make sure the fromAddress is the custom smart contract address since it's where the tokens are taken from. The destReceiver parameter is useful if the tokens don't need to be returned to the custom smart contract after the swap.

After the API response is received, the tx.data field can be passed as a parameter into the custom smart contract. Lastly, inside the contract there will be something along the lines of address(1inch_router_address).call(api_data), just make sure the 1inch_router_address - likely a constant - and the api_data - a function parameter - is correctly defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.