Encode Packed
Non-padded ABI encoding (abi.encodePacked) in viem-go
Loading...
Non-padded ABI encoding (abi.encodePacked) in viem-go
EncodePacked performs non-padded encoding (like Solidity’s abi.encodePacked): values are concatenated without 32-byte padding. It is a standalone function and does not require a parsed ABI.
import ( "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/abi")import ( "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/abi")
types := []string{"address", "uint256", "string"}values := []any{ common.HexToAddress("0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"), big.NewInt(420), "hello",}
packed, err := abi.EncodePacked(types, values)if err != nil { log.Fatal(err)}// packed is []byteEncodePacked(types []string, values []any) ([]byte, error)