Contract-Deployment
無法使用 Truffle 部署到私有鏈
我使用官方教程(https://wiki.parity.io/Demo-PoA-tutorial)創建了一個私有 Parity 鏈。然後我在我的 Truffle 配置中設置它:
module.exports = { networks: { private: { host: "127.0.0.1", port: 8540, network_id: "*" // Match any network id } } };
我可以使用 Truffle 控制台連接到它,但是當我嘗試部署時,它會永遠掛起:
松露(私人)>遷移–重置
使用網路“私人”。
執行遷移:1_initial_migration.js
部署遷移…
這是我在節點輸出中看到的內容:
7decca6e11722f25d1b633502f41ff986492b22638c27c8df5eac7e282541738880608081d5cb2d8 91cf0b9e9dc0a42867bfe68da161877ee4eb6e014@127.0.0.1:30300 2018-07-01 19:30:20 TRACE rpc Request: {"jsonrpc":"2.0","id":25,"method":"eth _accounts","params":[]}. 2018-07-01 19:30:20 DEBUG rpc Response: {"jsonrpc":"2.0","result":["0x00bd138 abd70e2f00903268f3db08f2d25677c9e"],"id":25}. 2018-07-01 19:30:20 TRACE rpc Request: {"jsonrpc":"2.0","id":26,"method":"net _version","params":[]}. 2018-07-01 19:30:20 DEBUG rpc Response: {"jsonrpc":"2.0","result":"8995","id" :26}. 2018-07-01 19:30:20 TRACE rpc Request: {"jsonrpc":"2.0","id":27,"method":"net _version","params":[]}. 2018-07-01 19:30:20 DEBUG rpc Response: {"jsonrpc":"2.0","result":"8995","id" :27}. 2018-07-01 19:30:20 TRACE rpc Request: {"jsonrpc":"2.0","id":28,"method":"eth _sendTransaction","params":[{"from":"0x00bd138abd70e2f00903268f3db08f2d25677c9e" ,"gas":"0x6691b7","gasPrice":"0x174876e800","data":"0x60806040523480156100105760 0080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916 908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f88061006060003960 00f300608060405260043610610062576000357c0100000000000000000000000000000000000000 000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780 638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b50 6100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001 90929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082 815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b6040 51808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffff ffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b50610157 6004803603810190808035906020019092919050505061026c565b005b6000806000905490610100 0a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffff ffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d5781905080 73ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff16 7c010000000000000000000000000000000000000000000000000000000002815260040180828152 602001915050600060405180830381600087803b15801561022457600080fd5b505af11580156102 38573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473 ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffff ffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16 3373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600 a165627a7a72305820f447dde0ef1d4d3a1752d10ae91ef75165287db6411fe180a975e1e0543517 ca0029"}]}. 2018-07-01 19:30:25 Verifier #6 INFO import Imported #37 5c74:10ce (0 txs, 0.0 0 Mgas, 0.87 ms, 0.56 KiB) 2018-07-01 19:30:27 IO Worker #3 INFO import 1/25 peers 14 KiB chain 20 KiB db 0 bytes queue 10 KiB sync RPC: 0 conn, 0 req/s, 51 чs 2018-07-01 19:30:57 IO Worker #3 INFO import 1/25 peers 14 KiB chain 20 KiB db 0 bytes queue 10 KiB sync RPC: 0 conn, 0 req/s, 51 чs
因此,如您所見,請求永遠不會得到響應。
**更新:**每當我發送一個簡單的交易時,都會發生同樣的結果:它永遠卡住了。
想通了。我需要解鎖我正在部署的帳戶。出於某種原因,Parity 沒有告訴我這件事,所以我花了 2 個小時猜測。
我使用 –unlock 命令行選項解鎖了我的帳戶。
很難這樣說。這是我會嘗試的事情:
驗證是否是防火牆問題。- ping 你正在執行的埠
驗證它不是奇偶校驗問題。- 試試geth
驗證它不是 Truffle 問題。嘗試使用 etherlime 來部署您的合約。這是一個快速的片段:
const etherlime = require('etherlime'); const ICOTokenContract = require('./build/contracts/ICOToken.json'); const defaultConfigs = { gasPrice: 20000000000, gasLimit: 4700000 } const deployer = new etherlime.InfuraPrivateKeyDeployer('Your Private KEY', 'ropsten', 'Your infura API key', defaultConfigs); const contractWrapper = await deployer.deploy(ICOTokenContract); // Make sure you call this method in an async function or use it as a promise without await
您可以在此處找到更多範例