Skip to main content

Abstract

The x/bank module in Stable SDK only provides basic token management features. Every token can be transferred to any account without any restriction and users cannot delegate other account for transferring their tokens to other accounts. For these reasons, the bank precompiled contract offers additional authorization and delegation features on top of the existing x/bank module in Stable SDK.

Contents

  1. Concepts
  2. Configuration
  3. Methods
  4. Events

Concepts

This precompiled contract provides ERC20 standard methods - such as transfer and balanceOf for transfer and transferFrom, approve and allowance for delegation. These methods can be called directly without requiring the contract address to be registered. However, mint and burn methods require the contract address to be whitelisted, registered by the x/precompile module.
Additional verification process can guarantee that token contract, calling this precompiled contract, is authorized. Governance proposal is required to register token contract address and its denom to whitelist in x/precompile module.

Configuration

Contract address and gas cost is predefined.

Contract Address

  • 0x0000000000000000000000000000000000001000 for gUSDT (gas token)
  • 0x0000000000000000000000000000000000001003 for STABLE (governance token)

Methods

mint

Mints requested amount of new tokens and transfer to the account. The amount of tokens to be minted must be greater than zero. PrecompiledBankMint is emitted when the tokens are successfully minted and transferred to the account. NOTE:
  • Minting governance token minting is prohibited.
  • Caller contracts calling mint method are must be registered in x/precompile module.

Inputs

Outputs

burn

Burns requested amount of tokens from the account. The amount of tokens to be burned must be greater than zero. PrecompiledBankBurn is emitted when the tokens are successfully burned. NOTE:
  • Burning governance token is prohibited.
  • Caller contracts calling mint method are must be registered in x/precompile module.

Inputs

Outputs

transfer

Transfers requested amount of tokens from sender to the recipient. Token must be set sendable. The amount of tokens to be transferred must be greater than zero. PrecompiledBankTransfer is emitted when the tokens are successfully transferred.

Inputs

Outputs

transferFrom

Transfers requested amount of tokens from owner to recipient by authorized spender within the limits of the allowance. Token must be set sendable. The amount of tokens to be transferred must be greater than zero and less than or equal to the current allowance. PrecompiledBankTransfer is emitted when the tokens are successfully transferred.

Inputs

Outputs

multiTransfer

Transfers tokens from single account to multiple accounts. Token must be set sendable. The amount of tokens to be transferred to each recipient must be greater than zero. PrecompiledBankTransfer is emitted per each recipient when the tokens are successfully transferred.

Inputs

Outputs

approve

Authorizes a spender to transfer tokens from the owner’s account. The amount of tokens to be authorized must be greater than zero. PrecompiledBankApproval is emitted when the authorization is successfully set.

Inputs

Outputs

revoke

Revokes the authorization of spender for transferring tokens from owner. PrecompiledBankRevoke is emitted when the authorization is successfully revoked.

Inputs

Outputs

balanceOf

Returns balance of tokens from the account.

Inputs

Outputs

totalSupply

Returns total supply of tokens.

Inputs

none

Outputs

allowance

Returns the amount which spender is still allowed to withdraw from owner.

Inputs

Outputs

Events

All events emitted from this precompiled contract are prefixed with PrecompiledBank. To avoid ambiguity, token contract calling this precompiled contract should avoid using event names with the same prefix.

PrecompiledBankMint

PrecompiledBankBurn

PrecompiledBankTransfer

PrecompiledBankApproval

PrecompiledBankRevoke