> 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/account/deploy_contract.md).

# deploy\_contract

部署合约。

## 方法定义

```python
def deploy_contract(self, abi: dict, bytecode: HexBytes, value: Wei = Wei(0), gas_price: Optional[Wei] = None, *args: Optional[Any]) -> Optional[TransactionReceiptData]
```

## 参数说明

| 参数         | 类型             | 说明                         |
| ---------- | -------------- | -------------------------- |
| abi        | dict           | 合约 ABI                     |
| bytecode   | HexBytes       | 合约字节码                      |
| value      | Wei            | 发送给合约的原生代币数量,默认为 0         |
| gas\_price | Optional\[Wei] | Gas 价格,默认使用链上当前 gas\_price |
| \*args     | Optional\[Any] | 传给合约构造函数的参数                |

## 返回值

返回 TransactionReceiptData 对象,当合约部署成功时,返回值中会额外添加"contract"字段(Contract 实例)。其他字段与 send\_transaction 相同。

## 示例代码

```python
# 部署合约
abi = [...] # 合约 ABI
bytecode = HexBytes("0x...") # 合约字节码

receipt = account.deploy_contract(
    abi=abi,
    bytecode=bytecode,
    value=Web3.to_wei(0.1, 'ether'),  # 发送 0.1 ETH 到合约
    gas_price=Web3.to_wei(50, 'gwei')  # 使用 50 Gwei 的 gas 价格
)

if receipt and receipt.transaction_status:
    print(f"Contract deployed at: {receipt.contract_address}")
    # 可以直接使用返回的合约实例
    contract = receipt.contract
```


---

# 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/account/deploy_contract.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.
