Can't get my deployment contract from deployments #6016
-
I use new version of hardhat with toolbox. const contracts = await deployments.fixture("raffle")
const raffleContractInstance = contracts["Raffle"]
const raffleContract = await ethers.getContractAt(
"Raffle",
raffleContractInstance.address,
deployer,
)
console.log(raffleContractInstance.address)
raffle = raffleContract.connect(deployer) to immitate raffleContract = await ethers.getContract("Raffle") And it worked for sometime, while I was testing on hardhat network. To solve this issue I used my only contract that has chainlink linked by importing abi: const { abi, contractAddress } = require("../../constants")
accounts = await ethers.getSigners()
player = accounts[0]
raffle = new ethers.Contract(contractAddress, abi, player) This code works fine, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So, you can deploy your contract once on sepolia, using yarn hardhat deploy, and then run the tests. Code snippet: const _raffle = await deployments.get("Raffle")
const raffleContract = await ethers.getContractAt("Raffle", _raffle.address, deployer) |
Beta Was this translation helpful? Give feedback.
So, you can deploy your contract once on sepolia, using yarn hardhat deploy, and then run the tests.
But in test do some modification, instead of using fixture which deploys new contract everytime, you can use get method of deployments, which will get the most recent deployment.
Code snippet: