EVM package deployment with ZeppelinOS - Part III: Linking to mainnet

Pulling it all together

Now that you've created your first EVM package, let's go through the
steps you would take to link it to your project as if you were linking
directly from NPM. These commands you already know, so I'll just run
through them quickly:

This will install your NPM package and add it to your zos.json file
as a dependency. You will also now find your linked contract in the
node modules folder. Open it up and you will see the ZeppelinOS
project configuration files along with your contract and build
folders.

For convenience, I've already deployed our linked list to NPM, so if you
don't want to deploy your own, you can use:

zos link zos-linkedlist

Testing

Return to your myproject2 top level, and create a new contract to test
the linked LinkedList contract. In your contracts folder, make a new
contract called QuickContract.sol. Note that for the import of the
LinkedList NPM module, I refer to the folder by the name "LinkedList."
As you will not be able to publish your NPM package under that name, be
sure to reference the module name according to the name you gave your
NPM package.

This is a fairly simple contract designed to test the basic functions of
the LinkedList.sol contract. Note that the first function
setLinkedList() takes an instance of LinkedList as an address. This is
how the QuickContract knows where the LinkedList contract is deployed,
but remember, this address will actually be the proxy contract, which
will serve as the permanent address for the contract but actually points
to the LinkedList implementation we deployed earlier. When we call into
the proxy, the proxy will forward the contract call to the logic code as
managed by ZeppelinOS. To upgrade your contract, you can tell the proxy
to point to a new logic contract, keeping the same address but with new
logic. As upgradable smart contracts are outside of the scope of this
tutorial, I encourage you to see this article for more information.

Now, from the top level of our project, we're going to add QuickContract
to the project:

zos add QuickContract

The next command will push our changes to the blockchain:

zos push --deploy-dependencies --network local

Let's take a quick look at the flag --deploy-dependencies while we have
deployed our NPM contract to the Ethereum mainnet. For testing purposes,
we're testing again on our local blockchain. ZeppelinOS will need to
also deploy its own copy of the LinkedList.sol to this development
blockchain in order to link to it. We only need to do this in cases
where the dependencies are not already deployed on our blockchain (since
we just created it when we started Ganache!), and we only need to do it
once. If you have successfully deployed to the mainnet, you will not
need to do this again.

As before, you need to create an instance of our contract:

zos create QuickContract

Be sure to call the LinkedList.sol contract initializer (ZeppelinOS
will remind you if you forget):