The World’s Largest Online Community for Developers

'; blockchain - How to deploy multiple solidity smart contracts that uses functions of each other? - LavOzs.Com

I have three smart contracts say a.sol, b.sol and c.sol... Out of these three, first two are independent smart contracts whereas c.sol uses the functions of a.sol and b.sol and thus c.sol requires to "import" the first two smart contracts. "Import" works locally but how to deploy all of them via remix/truffle on testnet such that c.sol can still access the functions of a.sol and b.sol?

Does your contract a and b suppose to be stand alone contracts that will be used regardless of contract c? ie: user store data in contract a, which will be used by contract c

If so, then you can have contract a and b as variables of contract c like this


contract A {
  function doSomething() {


contract C {
  A a;

  function setA(address addressOfContractA) {
    a = A(address);

  function makeADoSomething() {


If your project was created with Truffle, you can set up c.sol in the following way:

import "./a.sol";
import "./b.sol";

contract c is a, b {

If this is the structure of your code, you will be able to deploy your Truffle project using truffle migrate (provided your migrations are set up correctly).

Interacting a smart contract from Java application
Linking together smart contracts at deployment
The contract code couldn't be stored, please check your gas limit : Ethereum Smart Contract Deployment Failed:
how to create new ethereum/solidity contract for each test in javascript/truffle
Testing Deployed Smart Contract on Truffle
Access a smart contract that is deployed on the Ropsten network from an App
Building React front end for etherum solidity smart contract
How to deploy two smart contracts that inherit from each other to test network together?