Documentation ¶
Index ¶
- Constants
- func ParseBalancesArgs(args []interface{}) (sdk.AccAddress, error)
- func ParseSupplyOfArgs(args []interface{}) (common.Address, error)
- type Balance
- type Precompile
- func (Precompile) Address() common.Address
- func (p Precompile) Balances(ctx sdk.Context, _ *vm.Contract, method *abi.Method, args []interface{}) ([]byte, error)
- func (Precompile) IsTransaction(_ string) bool
- func (p Precompile) RequiredGas(input []byte) uint64
- func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)
- func (p Precompile) SupplyOf(ctx sdk.Context, _ *vm.Contract, method *abi.Method, args []interface{}) ([]byte, error)
- func (p Precompile) TotalSupply(ctx sdk.Context, _ *vm.Contract, method *abi.Method, _ []interface{}) ([]byte, error)
Constants ¶
const ( // PrecompileAddress defines the bank precompile address in Hex format PrecompileAddress string = "0x0000000000000000000000000000000000000804" // GasBalanceOf defines the gas cost for a single ERC-20 balanceOf query GasBalanceOf = 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 )
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 ¶
ParseSupplyOfArgs parses the call arguments for the bank SupplyOf query.
Types ¶
type Precompile ¶
type Precompile struct { cmn.Precompile // contains filtered or unexported fields }
Precompile defines the bank precompile
func NewPrecompile ¶
func NewPrecompile( bankKeeper bankkeeper.Keeper, erc20Keeper erc20keeper.Keeper, ) (*Precompile, error)
NewPrecompile creates a new bank Precompile instance as a PrecompiledContract interface.
func (Precompile) Address ¶
func (Precompile) Address() common.Address
Address defines the address of the bank compile contract. address: 0x0000000000000000000000000000000000000804
func (Precompile) Balances ¶
func (p Precompile) Balances( ctx sdk.Context, _ *vm.Contract, method *abi.Method, args []interface{}, ) ([]byte, error)
Balances returns all the native token balances (address, amount) for a given account. This method charges the account the corresponding value of an ERC-20 balanceOf call for each token returned.
func (Precompile) IsTransaction ¶
func (Precompile) IsTransaction(_ string) 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 ¶
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 native supply of a given registered erc20 token.
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 the native tokens. This method charges the account the corresponding value of a ERC-20 totalSupply call for each token returned.