0

I tried to use Remix to test a Smart Contract:

/********************************************************************
* Make bids with ETH or an ERC20 Token specified by the NFT seller.*
* Additionally, a buyer can pay the asking price to conclude a sale*
* of an NFT.                                                      *
********************************************************************/

function makeBid(
    address _nftContractAddress,
    uint256 _tokenId,
    address _erc20Token,
    uint128 _tokenAmount
)
    external
    payable
    auctionOngoing(_nftContractAddress, _tokenId)
    onlyApplicableBuyer(_nftContractAddress, _tokenId)
{
    _makeBid(_nftContractAddress, _tokenId, _erc20Token, _tokenAmount);
}

This is my JavaScript test:

await nftAuction
    .connect(user2)
    .makeBid(erc721.address, tokenId, zeroAddress, zeroERC20Tokens, {
        value: minPrice,
    });

These are my parameters for the function makeBid:

"0xD4Fc541236927...",1,"0x0000000000000000000000000000000000000000",0, {value:100,}

remix

The last one is an extra parameter, because the function is Payable and accept Ether transfers, it works well in Hardhat test, so I tried in Remix to input this line same as above and got this error from console "code=INVALID_ARGUMENT".

What's the right syntax to try this on Remix?

3
  • Can you make a screenshot of your input in remix ?
    – Majd TL
    Commented May 22, 2022 at 9:20
  • @MajdTL I updated the question...of course, for privacy, I truncated the first address. Commented May 22, 2022 at 9:51
  • 1
    Okay don’t add the value inside the function input field. Remix provide above the „deploy button“ 2 input fields for how much you want to send and in which unit (Wei, gwei, ether)
    – Majd TL
    Commented May 22, 2022 at 11:30

1 Answer 1

1

If you want to call payable function and send ether with the transaction in remix IDE, then you need to use those 2 provided input fields. The given amount is not related to the gas fees. Your contract must check the sent amount of ether with msg.value

Send-ether

5
  • Ok got it, so I keep 0 as value in my contract deployed and add a value in WEI or ETH etc. above at the top. Cool, thanks. Commented May 22, 2022 at 13:18
  • I’m not sure what you mean. Your contract MUST check the amount that has been sent with msg.value @NineCattoRules
    – Majd TL
    Commented May 22, 2022 at 16:29
  • You just need to remove {value:100} from your input field
    – Majd TL
    Commented May 22, 2022 at 16:31
  • Yes, it is what I said. Commented May 22, 2022 at 16:47
  • Since it's a similar question, could you please help me again? ethereum.stackexchange.com/q/128741/11332 Commented May 23, 2022 at 6:47

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.