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