Skip to content
alejandro-nieto-git edited this page Feb 3, 2022 · 4 revisions

Alastria Smart Contracts deployment explained

In the "Working with the Library, Smart Contracts and Examples WIP" section you can learn what to do to deploy all the contracts in the Alastria Identity Ecosystem. In this section we will explain why things are done this way as a more newbie friendly explanation.

Deployment using Truffle

Truffle is a Smart Contract testing framework and it makes the deployment proccess easier too. For truffle to work we have to edit the truffle.js config file to suit our environment. This is the truffle.js file mentioned in the other section:

module.exports = {
  networks: {
    'development': {
      host: "localhost",
      port: 8545,
      network_id: "*",
      gas: 0xffffff,
      gasPrice: 0x0,
    },
    'testnet': {
      host: "192.168.1.33",
      port: 22000,
      network_id: "*",
      gas: 0xffffff,
      gasPrice: 0x0,
      from: "0x64101c4f6b3394c249933983592ac0bbaf6b2f14"
    }
  },
  compilers: {
    solc: {
      version: "0.4.23", // A version or constraint - Ex. "^0.5.0"
      parser: "solcjs",  // Leverages solc-js purely for speedy parsing
      settings: {
        optimizer: {
          enabled: true,
          runs: 200   // Optimize for how many times you intend to run the code
        },
        evmVersion: "byzantium" // Default: "petersburg"
      }
    }
  }
};

In this file we have the JS Object "networks" in which we have to add the parameters of the networks we are going to deploy the Smart Contracts on. In this case we have the "development" network whose parameters are the defaults of a Ganache local network for testing purposes.

In the migrations folder we have the 1_initial_migration.js file which is always the first deployed contract on the network when we execute truffle deploy --network [network name]. For that reason if we are going to use the development network we have to change the Migrations.network_id to "*". Each deployed contract will have its own migration.js file, always starting with the correct migration number counting from 1 which is the migration number of the initial migration.

Upgrading previously deployed Alastria Smart Contracts

WIP