1

I am following a tutorial for a real estate web3.0 project. I am doing the exact same thing as he is but I don't know why I am still getting an error.

This is my contract Escrow.sol

contract Escrow {
address public nftAddress;
address payable public seller;
address public inspector;
address public lender;

mapping(uint256 => bool) public isListed;
mapping(uint256 => uint256) public purchasePrice;
mapping(uint256 => uint256) public escrowAmount;
mapping(uint256 => address) public buyer;

constructor(
    address _nftAddress,
    address payable _seller,
    address _inspector,
    address _lender
) {
    nftAddress = _nftAddress;
    seller = _seller;
    inspector = _inspector;
    lender = _lender;
}

function list(
    uint256 _nftID,
    uint256 _purchasePrice,
    uint256 _escrowAmount,
    address _buyer
) public {
    // transfer NFTs from seller to this contract
    IERC721(nftAddress).transferFrom(msg.sender, address(this), _nftID);

    isListed[_nftID] = true;
    purchasePrice[_nftID] = _purchasePrice;
    escrowAmount[_nftID] = _escrowAmount;
    buyer[_nftID] = _buyer;
}

}

And I am testing it like this

 const { expect } = require("chai");
const { ethers } = require("hardhat");

const tokens = (n) => {
  return ethers.utils.parseUnits(n.toString(), "ether");
};

describe("Escrow", () => {
  let buyer, seller, inspector, lender;
  let realEstate, escrow;

  beforeEach(async () => {
    // setup Accounts
    [buyer, seller, inspector, lender] = await ethers.getSigners();

    //Deploying Real Estate contract
    const RealEstate = await ethers.getContractFactory("RealEstate");
    realEstate = await RealEstate.deploy();

    //Mint
    let transaction = await realEstate
      .connect(seller)
      .mint(
        "https://ipfs.io/ipfs/QmQVcpsjrA6cr1iJjZAodYwmPekYgbnXGo4DFubJiLc2EB/1.json"
      );
    await transaction.wait();

   

 const Escrow = await ethers.getContractFactory("Escrow");
    escrow = await Escrow.deploy(
      realEstate.address,
      seller.address,
      inspector.address,
      lender.address
    );

    //Approve property
    transaction = await realEstate.connect(seller).approve(escrow.address, 1);
    await transaction.wait();

    //List property
    transaction = await escrow
      .connect(seller)
      .list(1, buyer.address, tokens(10), tokens(5));
    await transaction.wait();
  });

 

  describe("Listing", () => {
    it("Updates as listed", async () => {
      const result = await escrow.isListed(1);
      expect(result).to.be.equal(true);
    });

    it("Returns buyer", async () => {
      const result = await escrow.buyer(1);
      expect(result).to.be.equal(buyer.address);
    });

    it("Returns Purchase Price", async () => {
      const result = await escrow.purchasePrice(1);
      expect(result).to.be.equal(tokens(10));
    });

    it("Returns escrow Amount", async () => {
      const result = await escrow.escrowAmount(1);
      expect(result).to.be.equal(tokens(5));
    });

    it("Updates Ownership", async () => {
      expect(await realEstate.ownerOf(1)).to.be.equal(escrow.address);
    });
  });
});

But after using npx hardhat test I get the Error

 1) Escrow
   "before each" hook for "Updates as listed":
 Error: invalid address or ENS name (argument="name", value={"type":"BigNumber","hex":"0x4563918244f40000"}, code=INVALID_ARGUMENT, version=contracts/5.7.0)

I can't find at which line the error is, although I have checked everything from his GitHub repo and everything is the same. If you guys can tell me how to find where the error is and how to solve it

3
  • It worked now, I just copy pasted the list function from GitHub and it was the same as the function I wrote but it now worked. Commented Nov 15, 2022 at 9:38
  • 1
    Debugging is difficult when you're using other language to test Solidity code. Consider using Foundry. Commented Nov 15, 2022 at 10:06
  • That error means the problem is in the before or beforeEach. From the error message an address parameter is receiving something that doesn't look like an address "0x4563918244f40000". Perhaps you are missing some double quotes surrounding an address.
    – Ismael
    Commented Nov 15, 2022 at 20:44

1 Answer 1

0

In the contract, following function's first 3 params are uint256 and last one is address

function list(
    uint256 _nftID,
    uint256 _purchasePrice,
    uint256 _escrowAmount,
    address _buyer
)

Have a look at code snippet you are using in beforeEach

//List property
 transaction = await escrow
   .connect(seller)
   .list(1, buyer.address, tokens(10), tokens(5));

Here you are passing address in 2nd argument and uint256 in 4th argument that is creating the issue. Just swap the positions of these arguments and it should work then.

1
  • This is not answering the question, but fixing the problem. The question was about the line number.
    – kiecodes
    Commented Apr 15, 2023 at 9: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.