bank

package
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GasBalances defines the gas cost for a single ERC-20 balanceOf query
	GasBalances = 2_851

	// GasTotalSupply defines the gas cost for a single ERC-20 totalSupply query
	GasTotalSupply = 2_477

	// GasSupplyOf defines the gas cost for a single ERC-20 supplyOf query, taken from totalSupply of ERC20
	GasSupplyOf = 2_477
)
View Source
const (
	// BalancesMethod defines the ABI method name for the bank Balances
	// query.
	BalancesMethod = "balances"
	// TotalSupplyMethod defines the ABI method name for the bank TotalSupply
	// query.
	TotalSupplyMethod = "totalSupply"
	// SupplyOfMethod defines the ABI method name for the bank SupplyOf
	// query.
	SupplyOfMethod = "supplyOf"
)

Variables

This section is empty.

Functions

func ParseBalancesArgs

func ParseBalancesArgs(args []interface{}) (sdk.AccAddress, error)

ParseBalancesArgs parses the call arguments for the bank Balances query.

func ParseSupplyOfArgs

func ParseSupplyOfArgs(args []interface{}) (common.Address, error)

ParseSupplyOfArgs parses the call arguments for the bank SupplyOf query.

Types

type Balance

type Balance struct {
	ContractAddress common.Address
	Amount          *big.Int
}

Balance contains the amount for a corresponding ERC-20 contract address.

type Precompile

type Precompile struct {
	cmn.Precompile
	// contains filtered or unexported fields
}

Precompile defines the bank precompile

func NewPrecompile

func NewPrecompile(
	bankKeeper cmn.BankKeeper,
	erc20Keeper erc20keeper.Keeper,
) (*Precompile, error)

NewPrecompile creates a new bank Precompile instance implementing the PrecompiledContract interface.

func (Precompile) Balances

func (p Precompile) Balances(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Balances returns given account's balances of all tokens registered in the x/bank module and the corresponding ERC20 address (address, amount). The amount returned for each token has the original decimals precision stored in the x/bank. This method charges the account the corresponding value of an ERC-20 balanceOf call for each token returned.

func (Precompile) IsTransaction

func (Precompile) IsTransaction(_ *abi.Method) bool

IsTransaction checks if the given method name corresponds to a transaction or query. It returns false since all bank methods are queries.

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(input []byte) uint64

RequiredGas calculates the precompiled contract's base gas rate.

func (Precompile) Run

func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)

Run executes the precompiled contract bank query methods defined in the ABI.

func (Precompile) SupplyOf

func (p Precompile) SupplyOf(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

SupplyOf returns the total supply of a given registered erc20 token from the x/bank module. If the ERC20 token doesn't have a registered TokenPair, the method returns a supply of zero. The amount returned with this query has the original decimals precision stored in the x/bank.

func (Precompile) TotalSupply

func (p Precompile) TotalSupply(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	_ []interface{},
) ([]byte, error)

TotalSupply returns the total supply of all tokens registered in the x/bank module. The amount returned for each token has the original decimals precision stored in the x/bank. This method charges the account the corresponding value of a ERC-20 totalSupply call for each token returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL