Seascape Network

Truffle Framework

Explains on how to update the smartcontract configuration inside the Truffle Framework.
We assume that you installed the `seascape` module in your Truffle 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.


Truffle framework uses the migration scripts. Therefore we need to update the migrations, by adding the CDN Write calls.
In the top of migration files for your smartcontracts, import the CDNWrite module from seascape package.
// loading the artifacts
// for example const MetaCoin = artifacts.require("MetaCoin");
let { CdnWrite } = require("seascape");
After importing the modules, the migration itself exports a module. That exported module is called by Truffle framework. What we need to do is to convert this exporting function into the asynchronous function. And wait when the smartcontract is deployed:
// Make the function asynchronous.
module.exports = async function(deployer) {
await deployer.deploy(MetaCoin); // Wait for the smartcontract to be 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.
Upon deployment, the Truffle will add the all necessary properties for CDN into the Smartcontract object.
So, let's show the full migration script that updates the CDN right after the smartcontract deployment:
const MetaCoin = artifacts.require("MetaCoin");
let { CdnWrite } = require("seascape");
module.exports = async function(deployer) {
await deployer.deploy(MetaCoin);
let truffleParams = {
projectName: 'greeter',
projectEnv: 'beta',
contractName: 'MetaCoin',
contractType: 'main',
contractAbi: MetaCoin.abi,
contractAddress: MetaCoin.address,
networkId: await deployer.network_id,
txid: MetaCoin.transactionHash,
owner: deployer.address,
// verifier: "", optionally
// fund: "", optioanlly
let cdnUpdated = await CdnWrite.setTruffleSmartcontract(truffleParams);
if (cdnUpdated) {
console.log(`CDN was updated successfully`);
} else {
console.log(`CDN update failed. Please upload it manually!`);
After deployment, we prepare the parameter of the configuration, by preparing the configuration parameters.
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 setTruffleSmartcontract() 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.