3

I wondered what happens if for example OpenZeppelin changes the path of a contract I have imported like this: import "@openzeppelin/contracts/token/ERC721/ERC721.sol";? Will my contract still be working as before?

I could imagine that the EVM searches for the exact same contract in its memory and then just changes the import to the path where the EVM stores this file... Just asking to make sure my contract still works in like 3 years after I use such imports

1
  • 1
    Just to be clear, do u mean after the deployment ? Because when the contract is deployed to the network then the imported contract (not a reference of it on GitHub) is copied and deployed within your contract and the code of both contract will never be changed
    – Majd TL
    Apr 4, 2021 at 20:18

2 Answers 2

2

@openzeppelin refers to the the OpenZeppelin package you installed locally. This is not a reference to the Github page, the contracts are really stored in your project in the node_modules folder. Moreover, the version of the package can be found in the package.json file.

Using import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; is equivalent to write a file ERC721.sol in your contracts folder and import it with import "./ERC721.sol"; in the targeted contract.

When you compile a smart contract you get a bytecode that "holds" the information of the contract and all its dependencies such as imported contracts. The EVM does not store contracts, it is a runtime environment which computes the state changes. It can only interpret bytecodes which represent instructions such as contract deployment or contract interaction.

4

I see where your doubt is coming from.

Remix allows imports directly from github for quick development.

But development environments such as truffle & hardhat do not support HTTP/HTTPS imports. And hence, you need a package manager(mostly npm) to add additional contracts.

Even though you are using package managers or HTTP/HTTPS imports, after compiling the generated bytecode does not need the source files from any location to run.

I hope this helps.

Your Answer

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

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