Hardhat Framework
Explains on how to update the smartcontract configuration inside the Hardhat Framework.
We assume that you installed the `seascape` module in your Hardhat project. If not then please follow the Seascape SDK/Installation instructions.
We assume that you already defined how to configure the smartcontracts path. So that you can give it to the website/backend developers. For more reminding please check the Configuration format page.
We also assume that you got the credentials and setted up the .env with the CDN credentials. For more information check the CDN Write module page.
Scripts
Hardhat uses the scripts to deploy the smartcontracts. Therefore we need to update the scripts that deploy the smartcontracts, by adding the CDN Write calls. By convention the scripts in the hardhat framework are kept inside the /scripts
directory.
In the top of script files for your smartcontracts, import the CDNWrite
module from seascape
package. I show example for Javascript and Typescript versions.
What we need to do now is to convert this main function that deploys the smartcontract into the asynchronous function. And wait when the smartcontract is deployed:
The reason that we have to wait until the deployment end is simple. We will add after it, the code that will update the Seascape CDN. But for that we need to be sure that smartcontract is deployed successfully.
So, let's show the full deployment script that updates the CDN right after the smartcontract deployment:
After deployment, we prepare the parameter of the configuration. The only thing that we need to pass to the CDN updating function is the networkId. The rest of the parameters (owner, txid, abi) are fetched from the smartcontract instance provided by the hardhat framework.
Check the <project name> and <project env>. Those are indicating the path of the configuration file.
Then, we set the configuration onto CDN using the setHardhatSmartcontract
() function of CdnWrite
module.
The uploaded smartcontract config will be available for checking at:
Once the smartcontract configuration is deployed onto the CDN, as the Smartcontract writer should share the project name, project environment, Smartcontract name, the methods to call, the logs to listen to the appropriate developers.
Last updated