Running out of gas error when trying to deploy my solidity smart contract

Hi @romis

Separating the library into another file just reduces the gas required for deploying the contract as the library is deployed separately, but doesn’t reduce the overall gas used in the deploy transactions.

When deploying a library and then a contract that uses the library, you need to link them. See the Truffle documentation on deployer.link

I can deploy the contract with the library in the same file to ganache-cli with the following config in the truffle-config.js

  networks: {
    development: {
     host: "127.0.0.1",     // Localhost (default: none)
     port: 8545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
    },
  },

  // Configure your compilers
  compilers: {
    solc: {
       version: "0.4.23",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      settings: {          // See the solidity docs for advice about optimization and evmVersion
       optimizer: {
         enabled: true,
         runs: 200
       },
       evmVersion: "byzantium"
      }
    }
  }

It would be great if you could tell us What are you working on? This would give some context for your contract. Also interested what network you are looking to deploy on (mainnet or a private network), especially given some of the information you want to include e.g. postal addresses.

Regards truffle console I was able to do the following using the version of the contract including the library (with the optimizer). I would start there to check you can access the contract:

truffle(development)> crud = await CrudAEOStructures.deployed()
truffle(development)> (await crud.totalAEOs()).toString()
'0'

If you don’t have already, suggest you create tests for your smart contract functions. See the Truffle documentation on writing tests in JavaScript
You can look at the OpenZeppelin tests for how these are done. e.g. SimpleToken.test.js

Regards a front end it depends what front end technologies you already know (e.g. React). We had a discussion recently about web3 front end libraries.
For just interacting with a contract from a desktop you could use Remix, uDapp or OneClickDapp

1 Like