# encode_function_args

Encodes function arguments with standard ABI encoding and omits the 4-byte function selector.

Canonical HTML: <https://determica.com/docs/functions/encode_function_args>

- Kind: scalar function
- Category: [Contracts and ABI](/docs/category/contracts-and-abi.md)
- Tags: ABI

Encodes function arguments with standard ABI encoding and omits the 4-byte function selector.

## Overload 1: encode_function_args(JSON, VARCHAR, ...args)

```sql
encode_function_args(JSON, VARCHAR, ...args)
```

Uses the same function selection and value coercion rules as encode_function_data, but returns only standard ABI argument bytes.

- Kind: scalar
- Execution context: Offline
- Behavior: Abi Arguments Encode
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Risks

- product_semantics:single_function_selector_literal_not_validated

### Inputs

- `abi` (JSON; required; positional) — Contract ABI JSON containing the target function.
- `function_name` (VARCHAR; required; positional) — Function name, canonical signature, or 4-byte selector literal. Use a canonical signature when the ABI contains overloaded functions.
- `function_args` (ANY; positional; variadic) — One SQL value per selected function input, in ABI order. The ABI determines each accepted SQL cast and the encoded Solidity type.

### Returns

Selector-free ABI arguments

Returns BYTES containing only the ABI-encoded function arguments, without the 4-byte selector.

- `encoded_args` (BYTES)

Selector-free ABI arguments. Returns BYTES containing only the ABI-encoded function arguments, without the 4-byte selector.

### Examples

_Local SQL · Local_

```sql
-- Encode transfer(address,uint256) arguments without the selector
WITH abi AS (
  SELECT '[{
    "type": "function",
    "name": "transfer",
    "inputs": [
      { "name": "to", "type": "address" },
      { "name": "value", "type": "uint256" }
    ]
  }]'::JSON AS abi_json
)
SELECT encode_function_args(
  abi.abi_json,
  'transfer(address,uint256)',
  '0x000000000000000000000000000000000000dEaD'::ADDRESS,
  parse_units('2500', 6)
) AS encoded_args
FROM abi;
```

## Guidance

### Build nested ABI payloads

Use encode_function_args when a protocol expects ABI-encoded function arguments nested inside another payload, or when reproducing Solidity abi.encode(...) output.

- Use encode_function_data for top-level contract calldata.
- Use the canonical signature when an ABI has overloaded functions.
- The ABI and argument coercion rules match encode_function_data.

```sql
WITH abi AS (
  SELECT '[{
    "type": "function",
    "name": "transfer",
    "inputs": [
      { "name": "to", "type": "address" },
      { "name": "value", "type": "uint256" }
    ]
  }]'::JSON AS abi_json
)
SELECT encode_function_args(
  abi_json,
  'transfer(address,uint256)',
  '0x000000000000000000000000000000000000dEaD'::ADDRESS,
  parse_units('2500', 6)
) AS encoded_args
FROM abi;
```

### Selector literals

A selector literal can select the only function in a single-function ABI, but the current implementation does not compare that literal with the function's derived selector.

Use a function name or canonical signature when selector validation is required.

### Choose the right ABI primitive

Choose by byte framing and direction: selector construction, standard arguments, calldata, packed bytes, raw words, calldata decoding, and return-data decoding are distinct operations.

- function_selector hashes already-canonical signature text exactly; function_selector_json builds a canonical signature from one JSON ABI fragment first.
- encode_function_args emits selector-free standard ABI arguments; encode_function_data prefixes those same bytes with the 4-byte selector.
- abi_encode_packed concatenates compact scalar encodings without standard ABI offsets, lengths, or 32-byte padding; evm_abi_word always emits exactly one padded 32-byte word.
- decode_function_data consumes and validates selector-prefixed calldata inputs; call_decode consumes selector-free function return bytes.

```sql
SELECT
  function_selector('transfer(address,uint256)') AS selector,
  encode_function_data(
    '[{"type":"function","name":"transfer","inputs":[{"type":"address"},{"type":"uint256"}]}]'::JSON,
    'transfer(address,uint256)',
    '0x000000000000000000000000000000000000dEaD'::ADDRESS,
    1::UINT256
  ) AS calldata;
```

## Related functions

- [encode_function_data](/docs/functions/encode_function_data.md) — Alternative
- [abi_encode_packed](/docs/functions/abi_encode_packed.md) — See Also
- [evm_abi_word](/docs/functions/evm_abi_word.md) — Alternative
- [function_selector](/docs/functions/function_selector.md) — See Also
- [keccak256](/docs/functions/keccak256.md) — Usually Before
