Welcome to Dev3
Search
K
🛠️

Deploy Contracts

Explains how to deploy contract using the SDK.
Deployment process is quite similar to executing the contract function explained in the previous chapter.
It consists of the three steps:
  • Create deployment request
  • Redirect the user to the link generated for this concrete deployment request
  • Wait for the user to complete the action and receive the deployed contract instance
Before creating the deployment request, you must decide on the type of the contract you'd like to deploy. All the supported contract types are listed on the Dev3 Dashboard, so make sure you've created your first project before moving on.
Finding the contract type from the Dev3 Dashboard
In the example above, it is shown how to find the list of the deployable contracts. We then selected one item from the list, of type ERC20 Mintable, and found its contract ID (highlighted at the end of the video): openzeppelin.erc20presetmintableburnabledummy
Contract ID is the unique indentifier of the smart contract implementation within the Dev3 Platform. Usually it contains the two parts: organization and and the implementation name.
For example:
"openzeppelin.erc20presetmintableburnabledummy"
references the ERC20PresetMintableBurnable dummy token (used for testing) created from the OpenZeppelin Smart Contracts collection.
The source code of this contract, but also of all of the other ones, can be found in the central Dev3 contracts collection. The collection folder structure translates to the contract ID. For the contract from example above, all of the data used for deployment is stored in the
If you'd like to see your contract in the collection, simply follow our guidelines and make a contribution which in turn will expose your contract on the platform, assign it a unique ID and let others (you included) deploy the contract instance using the Dashboard *OR* the SDK.
Now that you've found the contract ID, and obtained the SDK instance object (as explained in the initialization section), run the following steps to get the contract deployed:
1
// sdk object initialized as explained in the Initialization section
2
3
// 1) load contract manifest
4
const contractId = '<contract id found on the dashboard>';
5
const contractManifest = await sdk.getManifestById(contractId);
6
7
// 2) build the deployment request
8
const contractAlias = '<contract alias of your choice>'; // this will be used as your deployment identifier
9
const constructorParams = [
10
// <list of constructor params>
11
];
12
const deploymentOptions = {};
13
const deploymentRequest = await contractManifest.buildDeployment(
14
contractAlias,
15
constructorParams,
16
options
17
);
18
// deployment link is generated, redirect the user to execute the deployment
19
window.open(deploymentRequest.actionUrl, "_blank");
20
21
// 3) await the action completion
22
const contractInstance = await deploymentRequest.awaitResult();
23
24
// 4) you're done!
25
// you can now use the contractInstance object to interact with the contract,
26
// read the state, or execute functions (explained in chapters before)
27
Two things to note here:
Constructor parameters array used for initializing the contract is built the same way as when calling the functions on the smart contract. You can see the different possibilities here. You can see the list of the constructor parameters you have to provide in the same screen where you found the contract ID for the contract you wish to deploy. In the video above, for example, after we've opened the 'Create' screen for the token we want to deploy, we can see that there are two constructor parameters we have to provide: Token Name and the Token Symbol, just below the contract alias field. These two values we have to provide when building the deployment action.
Options object provided when building the deployment action can contain the following:
1
{
2
ethAmount?: string;
3
arbitraryData?: Map<string, object>;
4
screenConfig?: ScreenConfig;
5
callerAddress?: string;
6
redirectUrl?: string;
7
}
All the fields are optional and can all be skipped by passing an empty object as the configuration. However, if you wish to use some (or all) of these, more detail is given in the options section.