--- title: abi.encodeFunctionData description: "Builds smart contract calldata from a single function ABI fragment and arguments: the 4-byte selector plus ABI-encoded params, returned as hex without 0x." keywords: ["encodefunctiondata", "utils", "calldata", "abi encode", "function selector", "tronweb"] --- # abi.encodeFunctionData > Added in **6.4.0**. This method builds the **calldata** for a smart contract method: the 4-byte function selector followed by the ABI-encoded parameters. It is the building block behind contract calls, and is useful when you need the raw `data` field yourself (e.g. to pass to `triggerSmartContract` / `triggerConstantContract`, or for an offline transaction). For just the parameter encoding (without the selector), use [abi.encodeParamsV2ByABI](./encodeParamsV2ByABI.md). ### Usage ```js tronWeb.utils.abi.encodeFunctionData(funcABI, args); ``` ### Parameters | Parameter | Description | Data Type | | --------- | ----------- | --------- | | funcABI | A **single** function ABI fragment — `{ type: 'function', name, inputs, outputs? }` — **not** the whole ABI array. | object (`FunctionFragment`) | | args | Optional. The function arguments, in ABI order. Defaults to `[]`. | array | **Notes** - Pass **one** function fragment, not the whole contract ABI array — extract the entry for the method (e.g. `abi.find((f) => f.name === 'transfer')`). - The returned hex string has **no** `0x` prefix. - `args.length` must equal `funcABI.inputs.length`, otherwise it throws `Invalid arguments provided: expected N arguments, got M`. - A non-`function` fragment (or one without a `name`) throws `Invalid function ABI fragment provided: only "function" type fragments with a name are supported`. - TRON's `trcToken` is kept in the **selector** signature (TVM convention) but encoded as `uint256` in the parameters. Base58 addresses inside `args` are converted to hex automatically. ### Returns hex string - The calldata: `selector (8 hex chars)` + ABI-encoded parameters, **without** a `0x` prefix. ### Example ```js // transfer(address,uint256) const funcABI = { name: 'transfer', type: 'function', inputs: [ { name: 'to', type: 'address' }, { name: 'amount', type: 'uint256' }, ], outputs: [], }; const data = tronWeb.utils.abi.encodeFunctionData(funcABI, ['TMVQGm1qAQYVdetCeGRRkTWYYrLXuHK2HC', 100]); // output-start 'a9059cbb0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf0000000000000000000000000000000000000000000000000000000000000064' // output-end // a function without parameters returns only the selector tronWeb.utils.abi.encodeFunctionData({ name: 'totalSupply', type: 'function', inputs: [], outputs: [] }); // output-start '18160ddd' // output-end // trcToken stays in the selector, value is encoded as uint256 tronWeb.utils.abi.encodeFunctionData( { name: 'transfer', type: 'function', inputs: [{ name: 'id', type: 'trcToken' }], outputs: [] }, [1000100] ); // output-start 'e7bf839c00000000000000000000000000000000000000000000000000000000000f42a4' // output-end ```