日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

使用geth部署智能合約

  1. 啟動一個連接到節點的交互控制臺,您可以參考文檔開啟geth交互控制臺來建立一個交互控制臺

  2. 在交互控制臺輸入以下指令,創建一個以太坊賬戶。如果您已經在節點上創建了以太坊賬戶,您也可以使用已有賬戶完成后續操作。

    1. // create a account that use empty password
    2. var account = personal.newAccount("");
    3. // using an existing account in node
    4. // var account = eth.accounts[0]
    5. // unlock account for 300 seconds with empty password
    6. personal.unlockAccount(account, "", 300);
    7. // set it as default account
    8. web3.eth.defaultAccount = account;
  3. 使用solc或truffle等第三方編譯工具,編譯智能合約,獲取智能合約的ABI和字節碼(bytecode)。您可以參考編譯智能合約編譯您的智能合約。

  4. 在交互控制臺輸入以下示例命令,在Quorum網絡中部署智能合約。在您需要部署自己的智能合約時,您需要將abibytecode替換為您智能合約的編譯結果。

    1. // abi for contract
    2. var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
    3. // compiled solidity bytecode code using https://github.com/jpmorganchase/quorum-examples/blob/master/examples/7nodes/simplestorage.sol
    4. var bytecode = "0x6060604052341561000f57600080fd5b604051602080610149833981016040528080519060200190919050505b806000819055505b505b610104806100456000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605157806360fe47b11460775780636d4ce63c146097575b600080fd5b3415605b57600080fd5b606160bd565b6040518082815260200191505060405180910390f35b3415608157600080fd5b6095600480803590602001909190505060c3565b005b341560a157600080fd5b60a760ce565b6040518082815260200191505060405180910390f35b60005481565b806000819055505b50565b6000805490505b905600a165627a7a72305820d5851baab720bba574474de3d09dbeaabc674a15f4dd93b974908476542c23f00029";
    5. var address = ""
    6. var simpleContract = web3.eth.contract(abi);
    7. var simple = simpleContract.new(42, {
    8. from: account,
    9. data: bytecode,
    10. gas: 0x47b760
    11. }, function(e, contract) {
    12. if (e) {
    13. console.log("err creating contract", e);
    14. } else {
    15. if (!contract.address) {
    16. console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
    17. } else {
    18. console.log("Contract mined! Address: " + contract.address);
    19. address = contract.address
    20. console.log(contract);
    21. }
    22. }
    23. });
  5. 當部署智能合約的交易被共識節點打包,您可以在交互控制臺看到您部署的合約地址,后續您可以向該地址發起交易,調用智能合約。