The code of the IBEP20, IPantosInterface, PantosBaseToken and a reference implementation
IBEP20
The IBEP20 interface is a set of standardized functions and events that must be implemented by token contracts to be compatible with the Pantos Digital Asset Standard (PANDAS). It inherits from the ERC20 token standard, ensuring compatibility with various blockchain ecosystems.
The IPantosToken interface is a set of standardized functions and events that must be implemented by token contracts to be compatible with the Pantos Digital Asset Standard (PANDAS). It inherits from the ERC20 token standard, ensuring compatibility with various blockchain ecosystems. The interface defines additional functions and events specifically tailored for cross-chain functionality, such as pantosTransfer, pantosTransferFrom, pantosTransferTo, and getPantosForwarder. By implementing this interface, token contracts can utilize Pantos Hub's cross-chain functionality.
// SPDX-License-Identifier: UNLICENSEDpragmasolidity >=0.8.0 <0.9.0;pragmaabicoder v2;import"@openzeppelin/contracts/token/ERC20/IERC20.sol";import"./IBEP20.sol";/** * @title Pantos token interface */interfaceIPantosTokenisIERC20, IBEP20 {eventPantosForwarderSet(address pantosForwarder);eventPantosForwarderUnset();// Only callable by the trusted Pantos forwarderfunctionpantosTransfer(address sender,address recipient,uint256 amount)external;// Only callable by the trusted Pantos forwarderfunctionpantosTransferFrom(address sender,uint256 amount) external;// Only callable by the trusted Pantos forwarderfunctionpantosTransferTo(address recipient,uint256 amount) external;functiongetPantosForwarder() externalviewreturns (address);}
PantosBaseToken
The PantosBaseToken is a base token contract that implements the IPantosToken interface, providing a foundation for creating custom tokens that are compatible with the Pantos Digital Asset Standard (PANDAS). This base contract ensures that the necessary functions and events for cross-chain functionality are implemented correctly, simplifying the process of creating new tokens. Developers can inherit from PantosBaseToken and extend it with their custom logic to create a new token that is compatible with Pantos Hub and can be transferred between various blockchains seamlessly.
// SPDX-License-Identifier: UNLICENSEDpragmasolidity >=0.8.0 <0.9.0;pragmaabicoder v2;import"@openzeppelin/contracts/access/Ownable.sol";import"@openzeppelin/contracts/token/ERC20/ERC20.sol";import"../interfaces/IPantosToken.sol";/** * @title Pantos base token */abstractcontractPantosBaseTokenisIPantosToken, ERC20, Ownable {uint8private _decimals;addressprivate _pantosForwarder;constructor(stringmemory name_,stringmemory symbol_,uint8 decimals_)ERC20(name_, symbol_) { _decimals = decimals_; }modifieronlyPantosForwarder() virtual {require( _pantosForwarder !=address(0),"PantosBaseToken: PantosForwarder has not been set" );require( msg.sender == _pantosForwarder,"PantosBaseToken: caller is not the PantosForwarder" ); _; }/// @dev See {IPantosToken-pantosTransfer}.functionpantosTransfer(address sender,address recipient,uint256 amount)publicvirtualoverrideonlyPantosForwarder {_transfer(sender, recipient, amount); }/// @dev See {IPantosToken-pantosTransferFrom}.functionpantosTransferFrom(address sender,uint256 amount)publicvirtualoverrideonlyPantosForwarder {_burn(sender, amount); }/// @dev See {IPantosToken-pantosTransferTo}.functionpantosTransferTo(address recipient,uint256 amount)publicvirtualoverrideonlyPantosForwarder {_mint(recipient, amount); }/// @dev See {IBEP20-decimals} and {ERC20-decimals}.functiondecimals()publicviewvirtualoverride(IBEP20,ERC20)returns (uint8) {return _decimals; }/// @dev See {IBEP20-symbol} and {ERC20-symbol}.functionsymbol()publicviewvirtualoverride(IBEP20,ERC20)returns (stringmemory) {return ERC20.symbol(); }/// @dev See {IBEP20-name} and {ERC20-name}.functionname()publicviewvirtualoverride(IBEP20,ERC20)returns (stringmemory) {return ERC20.name(); }/// @dev See {IBEP20-getOwner} and {Ownable-owner}.functiongetOwner() publicviewvirtualoverridereturns (address) {returnowner(); }/// @dev See {IPantosToken-getPantosForwarder}.functiongetPantosForwarder()publicviewvirtualoverridereturns (address) {return _pantosForwarder; }function_setPantosForwarder(address pantosForwarder)internalvirtualonlyOwner {require( pantosForwarder !=address(0),"PantosBaseToken: PantosForwarder must not be the zero account" ); _pantosForwarder = pantosForwarder;emitPantosForwarderSet(pantosForwarder); }function_unsetPantosForwarder()internalvirtualonlyOwner { _pantosForwarder =address(0);emitPantosForwarderUnset(); }}
Example Token inherit from PantosBaseToken
The Example Token is a custom token that inherits from the PantosBaseToken. It is designed to be compatible with the Pantos Digital Asset Standard (PANDAS), making it easy to transfer the token across different blockchains. The Example Token has a name, symbol, and decimals value, which are set in the contract.
// SPDX-License-Identifier: UNLICENSEDpragmasolidity >=0.8.0 <0.9.0;pragmaabicoder v2;import"./PantosBaseToken.sol";/** * @title Pantos-compatible Example Token */contractMyTokenisPantosBaseToken {stringprivateconstant _NAME ="MyToken";stringprivateconstant _SYMBOL ="MT";uint8privateconstant _DECIMALS =18;/// @dev msg.sender receives all existing tokens.constructor(uint256 initialSupply)PantosBaseToken(_NAME, _SYMBOL, _DECIMALS) { ERC20._mint(msg.sender, initialSupply);// Contract is paused until it is fully initialized }/// @dev See {PantosBaseToken-_setPantosForwarder}.functionsetPantosForwarder(address pantosForwarder)externalonlyOwner {_setPantosForwarder(pantosForwarder); }}