一、有可以運行的合約node
二、如何部署到生產、web
打開geth /home/zuolong/testNet/geth_truff 打開命令 geth --identity "newEth" --rpc --rpccorsdomain "*" --datadir "/home/zuolong/geth_truff/data/00" --port 30303 --rpcapi "db,eth,net,web3" --networkid "20170922" --bootnodes "enode://56bf95a92da10d55d853be0125399201f1caa6c74cb69f99911af755e88893c5fad6484235b406f781c1f3af978d0366d3fd886b68fe4b9c32652a4ab5416790@172.20.10.5:30303" consolejson
查看區塊數量 > eth.blockNumberapi
1327babel
編輯器網絡
sudo ln -s /opt/sublime_text/sublime_text /usr/bin/sublcors
truffle的配置部署合約 truffle.jsdom
// Allows us to use ES6 in our migrations and tests. require('babel-register') module.exports = { networks: { live: { host: "localhost", //本地地址,由於是在本機上創建的節點 port: 8545, //Ethereum的rpc監聽的端口號,默認是8545 network_id: 201702 // 自定義網絡號 } } }; 編寫合約 Test.sol pragma solidity ^0.4.4; contract Test { function multiply(uint a) returns(uint d) { return a * 7; } } 2_deploy_contracts.js var Test = artifacts.require("./Test.sol"); module.exports = function(deployer) { deployer.deploy(Test); }; /build/contracts目錄下打開Test.json 而後獲取abi而且地址 { "contract_name": "Test", "abi": [--專用abi { "constant": false, "inputs": [ { "name": "a", "type": "uint256" } ], "name": "multiply", "outputs": [ { "name": "d", "type": "uint256" } ], "payable": false, "type": "function" } ], "unlinked_binary": "0x60606040523415600e57600080fd5b5b60978061001d6000396000f300606060405263ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663c6888fa18114603c575b600080fd5b3415604657600080fd5b604f6004356061565b60405190815260200160405180910390f35b600781025b9190505600a165627a7a723058200ec9483d33cf2385ee4541aac868d6f3f7b6b1bca6c1d4fecf6d348b3b2ef18e0029", "networks": { "999": { "events": {}, "links": {}, "address": "0x712fa9552945e3c689a63fee835f3cd1cc98f04e",數據的地址 "updated_at": 1507795101956 } }, "schema_version": "0.0.5", "updated_at": 1507796737757 }編輯器
在使用的時候abi的壓縮 在終端上解鎖 personal.unlockAccount("0x4c00224faec439c08abe669bd2b15e3530a6e754", "111111", 10000)ide
部署合約 truffle migrate --network live
注意:在編譯、部署以後,須要進行屢次挖礦動做纔可以在生成的build目錄下的json文件中出現networks。且屢次挖礦等待部署命令自動完成並退出才能夠。
查看狀態(此時須要挖礦,才能部署到私有連)
txpool.status { pending: 1, queued: 0 }
建立合約的實例 >abi = [{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"payable":false,"type":"function"}];
>> test=eth.contract(abi).at("0x734f1f002ced572647928d40e1ac4c00fa5d5b9c");
test.multiply.call(3) Ropsten