> For the complete documentation index, see [llms.txt](https://505876833.gitbook.io/gao-jin-yun-xin-xin-yong-chi-v1.0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://505876833.gitbook.io/gao-jin-yun-xin-xin-yong-chi-v1.0/ping-tai-bu-shu/zhi-neng-he-yue.md).

# 智能合约

### 环境需要

```
npm install -g truffle
```

### 环境配置

修改 truffle-config.js 中的网络信息

```
    development: {
     host: "10.201.1.239", //区块链部署机器     
     port: 8545, //链 RPC 端口
     network_id: "1337", // 链 ID   
     gas: 80000000, // gasLimit 设置，应当小于区块大小
     gasPrice: 0, // gas 价格在我们的场景中自然是 0
     type: "quorum"
    },
```

### 部署合约

```
cd contract
truffle migrate --reset //记录部署后 MainStstem 合约地址
```

{% hint style="info" %}
此处使用的是Truffle框架，它的部署脚本在 /migration 下面，在部署合约时需要输入两个参数，分别为平台名称和盟主地址，请按需就行设置。

注意，部署合约时应该确保 RPC 端口的账号处于解锁状态（truffle 似乎不需要手动解锁），可使用Geth客户端完成解锁

./geth attach <http://10.201.1.237:8545>

eth.accounts

personal.unlockAccount('address') //输入上面获得的地址，密码默认为空
{% endhint %}
