0

I have several contrats to deploy on different chains. Normally, when I just deploy the contract with truffle-v5 it creates/updates json object of artifacts by the path ./build/contracts/MyContract.json for each chain id.

So if I do in 1_MyContract.js

const GnosisSafe = artifacts.require("GnosisSafe");
await deployer.deploy(SafeProxy, DEPLOYED.GNOSIS_SAFE_MASTERCOPY);
safeProxyInstance = await SafeProxy.deployed();

I can use this contracts in the next migrator script, 2_MySecondContract.js just like this:

const GnosisSafe = artifacts.require("GnosisSafe");
safeProxyInstance = await SafeProxy.deployed();

it's already knows chain, address etc because first script saved that info into json object.


If I don't want to deploy new instance of the contract during migration I can use via at() function:

safeProxyInstance = await SafeProxy.at(DEPLOYED.MULTISIG);

but when I do the line above - it doesn't update json artifact object.

The question

What can I do to update json artifact object for the existing instance of the contact for particular chain?

1 Answer 1

0

To update an artifact, you can simply recompile the contract. But deployed smart contracts are immutable. That's their beauty. If you don't want to redeploy the contract, why you want to recompile it? You cannot simply update the artifact (recompile) and expect the deployed contract to update.


Edit:

The artifacts (also called ABI) are results of compilation and represents machine readable contract definition (not instance). Migration is process of deploying contracts on chain (local, testnet, mainnet) and for that you already need the artifacts (this creates an instance). The artifacts are not expected to change while migrating on chain and don't include contracts addresses nor any storage.

2
  • so use it in 2_ 3_ 4_ etc deployed scripts as dependency
    – lebed2045
    Oct 12, 2021 at 19:35
  • @lebed2045 I updated the answer to explain the migration process better. Take a look.
    – ashhanai
    Oct 12, 2021 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.