Seascape Network
EN
EN
  • Welcome to Seascape
  • Guides
    • How to use the Scape Store Swapping Feature
    • How to Play Profit Circus
    • Guide to NFT Brawl
    • Guide to Staking Saloon
    • Guide to Scape Forum
    • Guide to Zombie Farm
    • Bridge Your MSCP between MOVR and BSC
    • Guide to join the pCWS Pools and NFT Trading
  • SMARTCONTRACTS
    • Addresses
      • Lighthouse
      • Changelog
    • Installation
    • Seascape NFT (SCAPES)
    • Crowns (CWS) token
  • Game for Developers
    • API Urls
    • Seascape Nft
    • Game 2: NFT BRAWL
      • Leaderboard
    • Game 5: Zombie Farm
      • Glossary
      • Reward categories
      • Option categories
      • API call order
  • Scape Store (Marketplace)
    • Config
    • Nft Swap
    • RPC backend
    • Smartcontract Changelog
  • API changelog
  • Seadex
    • Intro
    • Local deployment
    • Addresses
    • Managing Token
      • Add supported token to Factory
  • Lighthouse (IDO)
    • API
    • Smartcontrontracts
      • Tiers
    • Installation
  • Seascape SDK
    • Intro
    • Installation
    • Features
      • Shared Smartcontract Parameters
        • Configuration Format
        • Seascape CDN Config
        • CdnWrite
          • Truffle Framework
          • Hardhat Framework
          • Non-framework update
        • CDN Read
      • Server Proof
        • Smartcontract Data
        • Proof of Server
Powered by GitBook
On this page

Was this helpful?

  1. Seascape SDK
  2. Features
  3. Shared Smartcontract Parameters
  4. CdnWrite

Truffle Framework

Explains on how to update the smartcontract configuration inside the Truffle Framework.

PreviousCdnWriteNextHardhat Framework

Last updated 2 years ago

Was this helpful?

We assume that you installed the `seascape` module in your Truffle project. If not then please follow the 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 page.

We also assume that you got the credentials and setted up the .env with the CDN credentials. For more information check the page.

Migrations

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!`);
        console.log(truffleParams);
    }
}

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.

Seascape SDK/Installation
Configuration format
CDN Write module
https://cdn.seascape.network/greeter/beta/config.jsoncdn.seascape.network
Check the Smartcontract Configuration