Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions precompiles/erc20/tx.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package erc20

import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi"
Expand Down Expand Up @@ -74,6 +75,12 @@ func (p *Precompile) transfer(
from, to common.Address,
amount *big.Int,
) (data []byte, err error) {
// Validate that the recipient is not the zero address (ERC-20 requirement).
// Transfers to address(0) would result in permanent token loss.
if to == (common.Address{}) {
return nil, fmt.Errorf("%w: %s", erc20.ErrERC20, "transfer to zero address")
}

coins := sdk.Coins{{Denom: p.tokenPair.Denom, Amount: math.NewIntFromBigInt(amount)}}

msg := banktypes.NewMsgSend(from.Bytes(), to.Bytes(), coins)
Expand Down