How to Link libraries and Deploy Contracts?

Hello, I am the builder of Root Protocol for TRON Hackathon 22 and the problem is that I cannot deploy my contracts to any network. My codebase is here: [Root-Protocol-TRON/tronboxMigration at main · KowalewskiPawel/Root-Protocol-TRON · GitHub](Root Protocol TRON)

First of all, following the documentation I have tried to deploy it to Shasta test network, however I was always getting bandwidth/energy errors. The only solution was moving to Nile Test Network, and now I have a problem that I cannot deploy the main contract, since it uses several other contracts such as itterable mappings and openzepplin contracts. I have tried to link them in way as below:

const Root = artifacts.require("./Root.sol");
const MappingPost = artifacts.require("./libraries/IterableMappingPosts.sol");
const Mapping = artifacts.require("./libraries/IterableMapping.sol");
const Base64 = artifacts.require("./libraries/Base64.sol");

module.exports = async function (deployer) {
  const mappingPosts = await deployer.deploy(MappingPost);
  const mapping = await deployer.deploy(Mapping);
  const base = await deployer.deploy(Base64);

  deployer.deploy(Root, mappingPosts.address, mapping.address, base.address);

It looks like it’s not enough and I am still getting this error:

ERROR: Root contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of Root: $547b32fc6746c199fc1452f334b82463ae$

Doest it mean that I should also deploy openzeppelin contracts myself and link all of them? Thanks for any help in advance! :slight_smile:


Looks like a pain ngl. Don’t even know how maintained tronbox is, I just use foundry as I would on any EVM chain, then I import the ABI and bytecode to a JS deploy script, where I deploy the contract with


You can re-use the libraries if you know the contract address of that library.

Or you can deploy your own library.