Required KAP20 Functions for SDK system

The contract that can be used with the SDK system as KAP20 must have two important functions as follows:

Function approveBySDK

function approveBySDK(
    address _owner,
    address _spender,
    uint256 _amount
) external override onlyExecutor returns (bool) 

This function acts like function approve(address spender, uint256 amount) external returns (bool), where _owner is User to be performed by the system.

Function transferFromBySDK

function transferFromBySDK(
    address _sender,
    address _recipient,
    uint256 _amount
) external override onlyExecutor returns (bool) {
    require(
      kyc.kycsLevel(_sender) >= acceptedKycLevel && kyc.kycsLevel(_recipient) >= acceptedKycLevel,
      "KAP20: Only internal purpose"
    );

    _transfer(_sender, _recipient, _amount);
    return true;
}

This function performs as transferFrom(

address sender,

address recipient,

uint256 amount

external returns (bool) _sender is the User the system will work on. The Allowance is not checked in the contract we give as an example.

The basic functions that the SDK system expects a contract to have when they added are:

  • The onlyExecutor modifier is responsible for allowing addresses generated by the SDK system to call the function to which the modifier is attached. And to prevent being called by an address that doesn't have permission to use.

  • Contract KAP20SDK, which Bitkub Chain distributes as a sample, is a standard contract that developers can use. Or modify it to fit the Business Usecase of the developer and the Contract that implements later from the Contract KAP20 that implements the Interface IKAP20 and IKToken.

  • The SDK JS Library expects the first Input Type Address to be a value the Library will not send. But it will be replaced with the Wallet Address of the Bitkub Next Access Token of the User who called the command.

Last updated