智能合约 helloworld

windows 平台 因此直接使用Remix在线编译环境web

新建hello.sol文件 编辑以下windows

Remix 右边侧栏 setting 选择合适的编译器版本 这里选择 0.4.19  ui

文件中输入以下内容   注意版本匹配命令行

pragma  solidity ^0.4.19;3d

contract hello {部署

function sayHello() public returns (string ret)
{
return "Hello , world !";
}
}get

编译...input

复制 web3deploy 内容 这里注意 因为是js版本  我本地不支持var 直接复制到文本 干掉var变量定义编译器

而后在geth命令行 建立帐户 string

personal.newAccount()  

这里要求输入密码 

而后解锁帐户

personal.unlockAccount(eth.accounts[0]);

而后将上面复制好的WEB3DEPLOY 内容粘贴

相似  

simplestorageContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]);

simplestorage = simplestorageContract.new( { from: web3.eth.accounts[0], data: '0x6080604052348015600f57600080fd5b5060a08061001e6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636d4ce63c146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000439050905600a165627a7a72305820e4f6d169a5bf00bf4117a17cd8c02f49d9c44fa18212a81b735ec793ea524efa0029', gas: '4700000' }, function (e, contract){ console.log(e, contract); if (typeof contract.address !== 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); } })

miner.start(1); 等待一秒 返回结果 

Contract mined! address 

则说明合约部署成功

miner.stop();

输入 

simplestorage.get();