I'm attempting to loop through an array of addresses to check if a certain address (parameter) is in the array.

//SPDX-License-Identifier: MIT

pragma solidity 0.8.14;

contract RSVP {

    address public Host;
    address[] public rsvpAddresses;

    constructor() {
        Host = msg.sender;

    /// Only the Host can call this function
    error OnlyHost();

    modifier onlyHost() {
        if (msg.sender != Host) {
            revert OnlyHost();

    function rsvp() public payable {
        require(msg.value == 1 ether);

    function eventStartCheckIn(address payable guest) public onlyHost {
        for (uint i = 0; i < rsvpAddresses.length; i++) {
            if (guest = rsvpAddresses[i])
            guest.transfer(1 ether);


The error is on line 31 (with the for loop and if statement). "Type address is not implicitly convertible to expected type address payable." & "Type address payable is not implicitly convertible to expected type bool." I feel like these errors occur because the if statement is comparing an address (guest) to an array position but I can't figure out how to fix this.

1 Answer 1


the error is because you are using one = instead of double == in the if statement

this should work:

if (guest == rsvpAddresses[i])

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.