How can we send ether to payable function in solidity?

Viewed 910

I `ve got this function at my .sol file

function enter() public payable{
        require(msg.value > .01 ether);
        players.push(msg.sender);
    }

But when i`m trying to send some eth on it from deployed file it says 'invalid address or ENS name'.

const lotteryContract = new ethers.Contract(
        addr,
        LotteryArtifact.abi,
        acc2
    )

    const tx ={
        from:acc2,
        value:ethers.utils.parseEther('2'),
    }

    await lotteryContract.enter(tx)

Seems like it`s syntactically error in this way of calling it.Also i tried to send it this way

 const tx ={
        to:lotteryContract.enter(),
        value:ethers.utils.parseEther('2'),
    }

   await acc1.sendTransaction(tx)

Testing this 'enter' function in remix ide logging this enter image description here

According to the screenshot can anyone explain does 0xf8e81D47203A594245E36C48e151709F0C19fBe8 means the 'enter' function address?

0 Answers
Related