KUB Docs
  • Introduction to KUB
  • Connect to KUB
  • KUB PoS
    • Increase block gas limit to 90M
    • Update GasPrice Instruction
    • Incident from chaophaya hardfork
    • Overview
    • Considerations
    • Validator Node
      • Node Requirements
      • Run Validator Node
      • Validator Staking
      • StakeManager Contract
      • ValidatorShare Contract
      • Slashing
    • Run Full Node
    • Run Archive Node
    • Chaindata Snapshot
    • Migration PoSA to PoS
    • Delegator
      • How to delegate
      • How to claim reward
      • How to unstake
  • Developer Center
    • ✨Getting Started
    • 🏆Project Tiers
    • 👨‍💻Connect Bitkub NEXT to register as a new user
    • ✔️Verify your identity via Bitkub NEXT (KYC or KYB)
    • 💰Subscribe to the KUB Developer Package
    • 🗳️Submit your project
      • 📗Create submit project
      • 📘Manage your project
        • Submit project
        • Create a new project version
        • Status of project version
      • 📙Manage project information
  • KUB SDK
    • NEXT SDK
      • NEXT SDK Code Cookbook
      • KUB SDK Compatible Smart Contract
        • Example Smart Contract for Testing
        • Example KUB SDK Compatible KAP20 Smart Contract
        • Example KUB SDK Compatible KAP721 Smart Contract
  • KUB Playground
    • Quick Start Guide on KUB Playground
  • KUB Layer 2
  • KUB Scan
  • RPC Service
    • JSON-RPC Endpoint
  • IPFS Service
    • IPFS Guideline
  • FAQ
  • Glossary
  • Reference and Service
    • KUB Whitepaper Version 3.3
    • Technical Paper Version 3.2
    • KUB Explorer
    • KUB Faucet
    • KUB Oracle
    • KUB Bridge
    • KKUB OTP
Powered by GitBook
On this page
  • Function approveBySDK
  • Function transferFromBySDK

Was this helpful?

  1. Guide for implementing a smart contract

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 1 year ago

Was this helpful?