Deploy a smart contract

The next step in our fixed-supply crowdsale SCUI flow is to actually deploy the contracts to the Ethereum Network.

Creating the real ERC20 token contract

Since we are deploying the actual contract, the SCUI is not simulating the deploy transaction to estimate the gas price. The SCUI will show the user the real thing.

contract/fixed-supply/deploy #step-2

The previous step (estimateTxCosts()) includes the next action to be taken by the user: deployToken()

This action triggers the next action (deployToken()), which readies the token to be deployed to the current network (mainnet or ropsten):

Let's have a closer look to the let receipt = await this.deployer.deployToken() method, it should be self-explanatory:

Web3 deploy

The following deployer method was developed following the web3 deploy method documentation as well as for the signTransaction and sendSignedTransaction methods.

contract/fixed-supply/deploy #step-2 on tx success

Creating the fixed-supply crowdsale contract

contract/fixed-supply/deploy #step-3

The pattern for deploying the fixed-supply crowdsale contract is the same:

  1. Set the current step (this.steps.deployToken) as complete

  2. Set the next step (this.steps.deployCrowdsale) as current

  3. Initiate the contract deployment (this.deployer.deployCrowdsale())

  4. Wait for the transaction to finish or handle errors

  5. Trigger the next step

contract/fixed-supply/deploy #step-3 on tx success

Transfer the ERC20 token supply to the crowdsale

This operation needs to be made after both the token contract and the crowdsale contract are deployed to the Ethereum network. You cannot transfer the token supply to the crowdsale if there's no crowdsale yet, right?

This transaction is cheap and shouldn't take long.

contract/fixed-supply/deploy #step-4
contract/fixed-supply/deploy #step-3 on tx success

Last but not least, the finish button should take the user to the next route contract/0x00123<crowdsale-address>/show/fixed-supply

Last updated