so i'v 2 smart contracts token.sol
contract Token is IERC20, ReentrancyGuard {
string private Name;
string private Sympol;
uint private Decimal;
uint private TotalSupply;
address public owner;
mapping (address user => uint balance ) BalanceOf;
mapping (address tokenOwner => mapping (address spender => uint amount )) Allowed;
mapping (address burner => uint amount ) public burnedTokens;
mapping (address burner => uint number) RewardCounter;
Stake private stake;
mapping(address => uint256 dateOfstackingEndsInUnixTimesStamp) public stakingPeriod;
constructor(string memory _name, string memory _sympol, uint _decimal, uint _totalSupply, address _stake) {
Name = _name;
Sympol = _sympol;
Decimal = _decimal;
TotalSupply = _totalSupply;
BalanceOf[msg.sender] = _totalSupply;
owner = msg.sender;
stake = Stake(_stake);
}
// the rest of the code ...
}
and i'v stake.sol
contract Stake {
Token private token;
mapping (address user => uint amount) stakeOf;
constructor(address _token) {
token = Token(_token);
}
//the rest of the code
this is how i deploy theme in token.js
let Token, token, Stake, stake
let accounts = []
let owner, user1, user2, user3, user4, burner, staker
beforeEach( async()=>{
// setup accounts
accounts = await ethers.getSigners()
owner = accounts[0]
user1 = accounts[1]
user2 = accounts[2]
user3 = accounts[3]
user4 = accounts[4]
burner = accounts[5]
staker = accounts[6]
// load Contracts
Token = await ethers.getContractFactory('Token')
Stake = await ethers.getContractFactory('Stake')
// deploy Contract
try {
stake = await Stake.deploy( token.address)
console.log(`stake address: ${stake.address}`);
} catch (error) {
console.error('Error deploying Stake contract:', error);
}
token = await Token.deploy(
'YasCoin', 'YCN', 18, YasCoin(1000),stake.address
)
})