artifacts.require('./RefundEscrow');

I’m trying to call the below contract in the test file:

const RefundEscrow = artifacts.require('./RefundEscrow');

But I get the following error:

Error: Could not find artifacts for ./RefundEscrow from any sources

Noting that the RefundEscrow.sol file is exist in @OpenZeppelin\contracts\payment\escrow

1 Like

I think it should be

const RefundEscrow = artifacts.require('RefundEscrow');

If you have a contract RefundEscrow

2 Likes

I have tried this, but I get the same error, and yes have a contract RefundEscrow

1 Like

A little weird, how about truffle compile --force and then run this script?

1 Like

Still not working, I have the same error

Can you share the code of your contract?

1 Like
pragma solidity >=0.5.1;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/WhitelistCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol";

contract PFBTokenCrowdsale is Crowdsale, MintedCrowdsale, CappedCrowdsale, WhitelistCrowdsale, RefundableCrowdsale {

	// Track investor contributions
	uint256 public investorMinCap = 10000000000000000; // 0.01 ether
	uint256 public investorHardCap = 350000000000000000000; // 350 ether
	mapping(address => uint256) public contributions;

constructor(
	uint256 _rate,
	    address payable _wallet,
	    ERC20 _token,
	    uint256 _cap,
	uint256 _goal
)
	Crowdsale(_rate, _wallet, _token)
	CappedCrowdsale(_cap)
	RefundableCrowdsale(_goal)
	public
{
	require(_goal <= _cap);
}

/**
  * @dev Returns the amount contributed so far by a sepecific user.
  * @param _beneficiary Address of contributor
  * @return User contribution so far
  */
  function getUserContribution(address _beneficiary)
public view returns (uint256)
  {
return contributions[_beneficiary];
  }

/**
  * @dev Extend parent behavior requiring purchase to respect investor min/max funding cap.
  * @param _beneficiary Token purchaser
  * @param _weiAmount Amount of wei contributed
  */
  function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
  )
internal view
  {
super._preValidatePurchase(_beneficiary, _weiAmount);
uint256 _existingContribution = contributions[_beneficiary];
uint256 _newContribution = _existingContribution.add(_weiAmount);
require(_newContribution <= investorHardCap, "The maximum investment amount is: 350 ether");
require(_newContribution >= investorMinCap, "The minimum investment amount is: 0.01 ether");
  }

  /**
 * @dev Extend parent behavior to update beneficiary contributions.
 * @param beneficiary Token purchaser
 * @param weiAmount Amount of wei contributed
 */
function _updatePurchasingState(
	address beneficiary,
	uint256 weiAmount
  	)
  		internal
  	{
    super._updatePurchasingState(beneficiary, weiAmount);
    contributions[beneficiary] = contributions[beneficiary].add(weiAmount);
}
}