Non-framework update

Explains how to upload the smartcontract configuration onto Seascape CDN

We assume that you installed the `seascape` module in your 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

Why would you update without the framework?

First, you would need the Configuration file itself. If the configuration doesn't exist, then CdnRead will create an empty configuration for you.

import { 
    CdnRead, 
    CdnWrite, 
    ConfigPath,             // project path
    SmartcontractConfig,     // smartcontract config object with address etc.
    SmartcontractPath         // smartcontract address path inside the config.json
} from "seascape";

let main = async() => {
    let path = {project: 'lighthouse', env: 'beta'} as ConfigPath;
    
    let initialized = await CdnRead.initConfig(path);
    if (!initialized) {
        console.log(`Global initializiation failed`);
        process.exit(1);
    } 
}

Once you called the CdnRead.initConfig(), it will make the configuration available at global.seascapeConfig variable.

Then we need to prepare the smartcontract that we want to update. Here is the rest of the main function().

    // CDN client
    let client = await CdnWrite.connectCdn(
        process.env.ALIBABA_REGION, 
        process.env.ALIBABA_ACCESSID, 
        process.env.ALIBABA_SECRET,
        process.env.ALIBABA_BUCKET
    );
    if (client === undefined) {
        console.log(`Could not connect to the CDN`);
        process.exit(2);
    }

    // Smartcontract Config
    let smartcontract = {
        name: "MSCP ALLO",
        address: "0x93Efe41A6a5377bC1d7DD43412fD14B4bA0134Fb",
        abi: "https://...",
    } as SmartcontractConfig;

    // Path of the smartcontract inside the config.json
    let smartcontractPath = {
        networkId: 1287,
        type: 'nfts'
    } as SmartcontractPath;

    // update the Smartcontract
    let updated = await CdnWrite.setSmartcontract(path, client, smartcontractPath, smartcontract);
    console.log(`Was CDN updated successfully? ${updated}`);

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:

Check the result of the custom configuration update.

Once the smartcontract configuration is uploaded 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