Deployments Getting Started

Deployments Getting Started

Deploying with Superblocks allows you to fully automate your process in a shared environment without ever exposing your private keys. Doing this unlock a number of features:

  • Deploy using Metamask, Ledger or Trezor. No more copy pasting into Remix or manually deploying from someone’s laptop.
  • Use your current CI provider (Travis, CircleCI, etc) or use ours available through the platform. Your choice!
  • Gain clarity around your deployments for your entire team and community. Per example, what was the real cost of your deployment in USD? What are the latest contract address for your contracts?
  • Track in a glance which commit was deployed to which network.
  • Gain full automatic back stack traceability to agiven deployment all the way from Mainnet by linking your commit information and CI job.

Setting up Deployments

Setting up your deployment is a 4-step process:

  1. Use any of our custom Web3 Providers. Here is an example in action: Truffle Reference Project.
  2. Create a new Deployment Space
  3. Create a new Deploy Token to authenticate
  4. Substitute those variables when configuring the Web3 provider

Configure Your providers

At the moment we have created 2 different providers to help track and sign deployment depending on your use case.

In order to provide full transparency we have open sourced both providers:

ManualSignProvider

This provider will allow you to sign your transactions directly in the browser using Metamask, Ledger or Trezor.

mainnetMetamaskProvider = new ManualSignProvider({ 
    process.env.deploymentSpaceId,
    process.env.token,
    from: '0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8', 
    endpoint: 'https://rinkeby.infura.io/v3/{your_private_key}',
    networkId: '1',
})

These are the parameters you need to provide:

  • deploymetSpaceId: The target deployment space inside Superblocks. Read more about them here.
  • token: A token you have generated in the platform to give you access to communicate with the deployments API. Read more about it here
  • from: The address you would like to sign the transactions with. We check this in the dashboard, making sure you don’t end up deploying with a different wallet.
  • endpoint: The rpc url pointing to your node.
  • networkId: The id of the network you would like to deploy to. We will automatically convert known ids to name their known names (mainnet, rinkeby, etc). We also add yet another security feature here making sure you don’t end up deploying to the wrong network when using Metamask.

Now that you have everything setup, you can run your deployment scripts as usual. This is an example using Truffle migrations but remember that you could use any other web3 lib like Web3JS or EtherJS.

Putting Truffle as an example:

...
    networks: {
        develop: {
            port: 8545
        },
        rinkeby_metamask: {
            provider: () => {
                
                // Let's not double create the provider (as we will create many deployments) as Truffle calls this function many times (◔_◔)
                if (!rinkebyMetamaskProvider) {
                    rinkebyMetamaskProvider = new ManualSignProvider({ 
                    deploymentSpaceId: '{space_id}',
                    token: '{token}',,
                    from: '0xEA6630F5bfA193f76cfc5F530648061b070e7DAd', 
                    endpoint: 'https://rinkeby.infura.io/v3/{your_api_code}',
                    networkId: '4',
                    })
                }

                return rinkebyMetamaskProvider;
                
            },
        network_id: '4'
    },
...
# Run your deployment scripts as normal
npx truffle  migrate --network=rinkeby_metamask --verbose-rpc

Once you start running your deployment scripts, head back to the dashboard and open your deployment space that you created. Your deployment will appear and will automatically start tracking the transactions for you.

Deployment Space Overview

Click on the latest deployment id and you wil be taken to the deployment details page. This will provide you with a list of all the environments into which you have deployed.

Deployment Details

SuperHdWalletProvider

This provider is built on top of Truffles widely used HDWallet Provider. It allows you to automatically sign your transactions locally and have the ability to track the entire deployment in Superblocks.

If you want to find more information about Truffles HDWallet provider, head to their Github Repo

 rinkebyProvider = new SuperHDWalletProvider({
    deploymentSpaceId,
    token,
    mnemonic,
    networkId: '4',
    provider: "https://rinkeby.infura.io/v3/14a9bebf5c374938b2476abe29ca5564"
});

These are the parameters you need to provide:

  • deploymetSpaceId: The target deployment space inside Superblocks. Read more about them [here][/docs/deployments/spaces/#section=deployments].
  • token: A token you have generated in the platform to give you access to communicate with the deployments API. Read more about it here
  • mnemonic: The 12 word mnemonic
  • from: The address you would like to sign the transactions with. We check this in the dashboard, making sure you don’t end up deploying with a different wallet.
  • endpoint: The rpc url pointing to your node.
  • networkId: The id of the network you would like to deploy to. We will automatically convert known ids to name their known names (mainnet, rinkeby, etc). We also add yet another security feature here making sure you don’t end up deploying to the wrong network when using Metamask.

Benefit of using our Provided CI

If you are using Superblocks built in CI (optional), we offer you some handy features to help connect different parts of the application life cycle.

We have added the possibility to connect your CI job with a given deployment. This allow you to:

  • in a single view, see the link between a certain job performing the deployment and the deployment details.
  • in a single view, track the progress of your job whilst simultaneously being able to sign and track the transactions (assuming you are using the ManualSignProvider).

Configuring Manual deployments

Adding when: manual to an automatically executed job configuration converts it to a manual job. Here you have an example of how a simply CI configuration would allow this:

version: 1
jobs:
  build:
    image: node:12
    script:
        - npm install
        - npx truffle compile

  test:
    image: node:12
    script:
        - npm install
        - npx truffle test

  deploy_rinkeby_metamask:
    image: node:12
    type:
        name: ethereum/deploy
    script:
        - npm install
        - npx truffle migrate --network rinkeby_metamask --reset

        
stages:
  - build_and_test:
      jobs: 
        - build
        - test
  - deploy:
      jobs:
        - deploy_rinkeby_metamask:
            when: manual

Then, when adding the when: manual flag to your job:

  • Superblocks will expose a Trigger manual job action in the UI for that job
  • Means that the deploy_rinkeby_metamask will only be triggered when the action gets clicked in the UI.

Trigger manual Job

Once the Trigger manual job gets clicked, Superblocks will fire your job and start performing the deployment.

CI Deployment job