enter image description here

I am practicing using the uniswap v3 router and i created a simple contract that attempts to swap a certain amount of ETH to dai. This is the function that does so

function convertETHToDAI() external payable {
    require(msg.value > 0, "You must send ETH");
    uint256 deadline = block.timestamp + 15; // using 'now' for convenience, for mainnet pass deadline from frontend!
    address tokenIn = WETH9;
    address tokenOut = multiDaiKovan;
    uint24 fee = 3000;
    address recipient = msg.sender;
    uint256 amountIn = msg.value;
    uint256 amountOutMinimum = 1;
    uint160 sqrtPriceLimitX96 = 0;

    ISwapRouter.ExactOutputSingleParams memory params = ISwapRouter.ExactOutputSingleParams(tokenIn,
    uniswap = IUniSwapRouter(UniswapAddress);

    uniswap.exactOutputSingle{value: msg.value}(params);

    (bool success, ) = msg.sender.call{value: address(this).balance }("");
    require(success, "Refund to caller failed");

I deploy it successfully to the rinkeby test network and try to call it and send ether with the truffle console and all i get is the

evalmachine.:1 await engine.convertETHToDAI{value: 0.1 ether}() ^

Uncaught SyntaxError: Unexpected token '{'

error shown in the image.

I am certain i am doing something wrong but i dont know what.


1 Answer 1


Maybe just the syntax:

await engine.convertETHToDAI({value: 0.1 ether})
  • it fails with this error evalmachine.<anonymous>:1 await engine.convertETHToDAI({value: 0.1 ether}) ^^^^^ Uncaught SyntaxError: Unexpected identifier Apr 25, 2022 at 6:02
  • Then it remains to convert ether to wei await engine.convertETHToDAI({value: 100000000000000000}) Apr 25, 2022 at 14:10

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.