Developer Guide

Update Token Contract

Update Token Contract Overview

This guide gives a step-by-step process to update a Token Contract with new functions or existing functions. The guide will cover the following steps:

  • Creating new Package
  • Deploying new Package
  • Publishing the Package to Updates Repository
  • Updating the Token Contract with new Package
  • 1

    Create New Package

    A New Package will be a smart contract which inherits an IPackage interface. The package will have the new functions or updated functions. You can define the following functions in the new package; these functions update the _methodImplementation mapping to store the package address against the function signature.


    `applyUpdateToSpecificVersion`
     - `version` - Specified version (eg. "1.0.1")
    
     ```solidity
     function applyUpdateToSpecificVersion(string calldata version) external;
     ```

    `applyUpdate`
     ```solidity
     function applyUpdate() external;
     ```

    While creating the new package, make sure to inherit the original storage of the token/context so that the storage is same order or else storage collision will occur.

    Also the original storage contains the COMPONENT_ID of the token/context.

  • 2

    Deploying new Package

    Once the new package is created, deploy the package to the network.

  • 3

    Publishing the Package to Updates Repository

    After deployment, the package should be published to the Updates Repository.

    Use the publishUpdate function of the IUpdatesRepository interface to publish the package with version string.


    solidity function publishUpdate(address updatePackage, string calldata version) external;

    Parameters


    Update Package

    Address of the package

    Version

    Version of the package. eg. "1.0.1"


  • 4

    Updating the Token Contract with new Package

    To update the token/context with the new package after publishing it to the updates repository, use the update function of the IUpgradable interface in the token/context smart contract.


    solidity function update() external;


    If you want to update the token with a specific version of the package, use the updateToSpecificVersion function.


    solidity function updateToSpecificVersion(string calldata version) external;

    Parameters


    Version

    Version of the package. eg. "1.0.1"

Interested in third-party integrations?

Contact our sales team for more information

Have questions?

View answers to the most common questions about our platforms and services

Search