Tutorials
Technical Guides
Featured Guides
Deploying a Flow Contract
In the Beginner Sample App tutorial, the contract has already been deployed and added to the Dapper Platform. However, if you want to deploy your own contracts, you will need to go through the following steps. We will use the MonsterMaker contract for the example, which you can deploy to your own address and use for your own dApp. These same steps apply for any contracts that you are deploying.
- Ensure that you have
flow
installed on your system. You can follow the instructions here. - Create a public and private key pair for the desired flow environment (testnet/mainnet)
This will generate a public/private key pair that will be used to create an account:
3. Sign in to flowport with your desired wallet. Flow port will allow you to create an account that you can use to deploy your contracts:
This will bring you to a dashboard display. Click on “Advanced” in the lower left:
4. Click on “Advanced” and then “Create New Account”
5. Paste your public key that was generated by flow
in the terminal in the first field, and leave the other fields as defaults. Click Submit:
6. When the transaction completes, scroll to the events section and look for the flow.AccountCreated
type. Copy the address
value. This is the address of your account and will be needed to deploying the contract.
7. Next we will need to use flow
to deploy the contract to our newly created account. Go back to the terminal, and create a directory you will use for the deployment (e.g. deploy-monster-maker). Switch to that directory and type flow init
:
8. This will create a default flow.json file that we will use to configure the deployment. Open flow.json in an editor such as VSCode:
9. Add your contract to this directory. For this example we will add the MonsterMaker contract. Note that the addresses for the NonFungibleToken
and the MetadataViews
refer to testnet addresses, since that is where we are deploying to:
10. Add the contract to the config and a section called “testnet-account” as below, adding the address generated from the account in flowport from step #6, and the private key generated in step #2. Note that the values of the testnet-account all match the values that were used when creating the account in flowport:
11. In order to deploy the contract, some flow is required to cover the cost of the transaction, and you will need to transfer some flow to your newly created account. Go to the Balances page on flowport:
12. Click “Send” and paste in the address of you Account (the address generated in step #6):
13. Go back to your terminal and execute the command
You should see the contract deployed successfully after a few seconds.
14. Validate the successful contract deployment by going to flow-view-source, and entering the account address:
You should see the contract deployed as below:
15. Go back to the Dapper Developer Dashboard and you can follow the steps outlined In the “Adding an App to Dapper Platform” Section to add your contract to your app.