Fix token deployment with contractAt

This commit is contained in:
Arnaud 2025-05-23 08:57:20 +02:00
parent 7cf952c63b
commit ba0882077c
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F
3 changed files with 19 additions and 11 deletions

View File

@ -39,6 +39,10 @@ Or you can you `npx` directly:
npx hardhat ignition deploy ignition/modules/marketplace.js --network localhost
```
To reuse a previously deployed `Token` contract, define the environment variable `TOKEN_ADDRESS`.
The deployment script will use `contractAt` from Hardhat Ignition to retrieve the existing contract
instead of deploying a new one.
Running the prover
------------------

View File

@ -18,15 +18,13 @@ module.exports = buildModule("Marketplace", (m) => {
const { verifier } = m.useModule(VerifierModule)
const configuration = m.getParameter("configuration", getDefaultConfig())
let marketplace
if (process.env.TOKEN_ADDRESS) {
marketplace = m.contractAt("TestToken", process.env.TOKEN_ADDRESS, {})
} else {
marketplace = m.contract("Marketplace", [configuration, token, verifier], {
const marketplace = m.contract(
"Marketplace",
[configuration, token, verifier],
{
from: deployer,
})
}
},
)
let testMarketplace
const config = hre.network.config

View File

@ -6,9 +6,15 @@ const MINTED_TOKENS = 1_000_000_000_000_000n
module.exports = buildModule("Token", (m) => {
const deployer = m.getAccount(0)
const token = m.contract("TestToken", [], {
from: deployer,
})
let token
if (process.env.TOKEN_ADDRESS) {
token = m.contractAt("TestToken", process.env.TOKEN_ADDRESS, {})
} else {
token = m.contract("TestToken", [], {
from: deployer,
})
}
const config = hre.network.config