> For the complete documentation index, see [llms.txt](https://poseidon.seaeye.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://poseidon.seaeye.cn/evm/contract/decode_function_calldata.md).

# decode\_function\_calldata

解码针对当前合约执行调用的 CallData,得出所调用的函数名称及其参数值。

## 方法定义

```python
def decode_function_calldata(self, calldata: HexStr) -> Optional[tuple]
```

## 参数说明

| 参数       | 类型     | 说明                  |
| -------- | ------ | ------------------- |
| calldata | HexStr | 对当前合约执行调用的 CallData |

## 返回值

| 类型               | 说明             |
| ---------------- | -------------- |
| Optional\[tuple] | 包含函数名称及其参数值的元组 |

返回的元组格式为: (function\_name, parameters\_dict)

* function\_name: 函数名称
* parameters\_dict: 包含参数名和值的字典

## 示例代码

```python
# 解码函数调用数据
calldata = "0xa9059cbb000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b0000000000000000000000000000000000000000000000000de0b6b3a7640000"

result = contract.decode_function_calldata(calldata)
if result:
    function_name, parameters = result
    print(f"Function Name: {function_name}")
    print(f"Parameters: {parameters}")

# 编码后解码验证
encoded = contract.encode_function_calldata(
    "transfer",
    "0xab5801a7d398351b8be11c439e05c5b3259aec9b",
    Web3.to_wei(1, 'ether')
)
if encoded:
    decoded = contract.decode_function_calldata(encoded)
    print(f"Decoded: {decoded}")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://poseidon.seaeye.cn/evm/contract/decode_function_calldata.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
