github.com/diadata-org/diadata@v1.4.593/scripts/deployContracts.sh (about)

     1  #! /usr/bin/env bash
     2  # abort script on error
     3  set -e
     4  # -----------------------------------------------------------------------
     5  # Script configuration
     6  # -----------------------------------------------------------------------
     7  # Project name
     8  PROJECT='DIA'
     9  # Project version
    10  VERSION='0.1.0'
    11  # Network to deploy
    12  if [ -z $1 ]
    13  then
    14      echo 'No network provided'
    15      NETWORK='development'
    16  else
    17      echo 'Network provided'
    18      NETWORK=$1
    19  fi
    20  # -----------------------------------------------------------------------
    21  # Network configuration
    22  # -----------------------------------------------------------------------
    23  case $NETWORK in
    24      'development' )
    25          echo 'Using network development'
    26          # Since is development is safe to erase all configs
    27          rm -f zos.dev*
    28          rm -f zos.json
    29          rm -rf build
    30          # Owner is the owner passed to ownables contracts
    31          # use accounts[0] for simplicity
    32          OWNER='0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1'
    33          # Admin is the account used to deploy and manage upgrades.
    34          # use accounts[9] for simplicity
    35          ADMIN='0x1df62f291b2e969fb0849d99d9ce41e2f137006e'
    36      ;;
    37      
    38      'rinkeby' )
    39          echo 'Using network rinkeby'
    40          # Owner is the owner passed to ownables contracts
    41          OWNER='0x05349268a998355280e55693b06B0823aB7C98cE'
    42          # Admin is the account used to deploy and manage upgrades.
    43          ADMIN='0x11aA0b53cbd2df11fa9e2D3CeA08d6F4EBd65e19'
    44      ;;
    45      * )
    46          echo 'network ['$NETWORK'] not implemented'
    47          echo 'please add network configuration before continuing'
    48          exit
    49      ;;
    50  esac
    51  # -----------------------------------------------------------------------
    52  # Project setup using zOS
    53  # -----------------------------------------------------------------------
    54  # Set zos session (network, admin, timeout)
    55  npx zos session --network $NETWORK --from $ADMIN --expires 36000
    56  # Compile contracts
    57  npx truffle compile
    58  # Initialize zOS project
    59  # NOTE: Creates a zos.json file that keeps track of the project's details
    60  npx zos init $PROJECT $VERSION -v
    61  # Register contracts in the project as an upgradeable contract.
    62  npx zos add DIAToken -v --skip-compile
    63  npx zos add Dispute -v --skip-compile
    64  # Deploy all implementations in the specified network.
    65  # NOTE: Creates another zos.<network_name>.json file, specific to the network used, which keeps track of deployed addresses, etc.
    66  npx zos push --skip-compile  -v
    67  # Request a proxy for the upgradeably contracts.
    68  # Here we run initialize which replace contract constructors
    69  # NOTE: A dapp could now use the address of the proxy specified in zos.<network_name>.json
    70  # instance=MyContract.at(proxyAddress)
    71  dt=$(npx zos create DIAToken --network $NETWORK --init initialize --args $OWNER -v)
    72  npx zos create Dispute --network $NETWORK --init initialize --args $dt -v