arnaucube
arnaucube/darkID-prototypePublic Self-hosted repository
darkID-prototype/eth/notes.md
eth/notes.mdRaw
 1- start node and blockchain syncing in testnet
 2```
 3geth --testnet --datadir ~/eth-testnet
 4```
 5
 6- create first account (wallet)
 7```
 8geth --testnet --datadir ~/eth-testnet account new
 9```
10
11- mine ethers in testnet
12```
13geth --testnet --datadir ~/eth-testnet --mine
14```
15
16- serve dapp running on localhost:8000 via RPC
17```
18geth --testnet --datadir ~/eth-testnet --rpc --rpccorsdomain "http://localhost:8000" --rpcapi eth,web3,personal
19```
20
21
22- generate ABI from contract.sol
23```
24solcjs --abi HelloWorldContract.sol
25```
26
27- generate the byte code
28```
29solcjs --bin HelloWorldContract.sol
30```
31
32
33- deploy contract via geth js console
34    - open geth console
35    ```
36    geth --testnet --datadir ~/eth-testnet console
37    ```
38
39    - in the console create the contract using ABI and BYTE CODE result from compilation
40    ```js
41    var abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}];
42    var code = '0x60606040527f48656c6c6f20576f726c64000000000000000000000000000000000000000000600090600019169055341561003957600080fd5b5b609d806100486000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314603d575b600080fd5b3415604757600080fd5b604d606b565b60405180826000191660001916815260200191505060405180910390f35b600054815600a165627a7a72305820f4c510e24a238337d5334b5b38a44e88ea53ef40f26aeb96eba4609cb72827cd0029';
43    web3.personal.unlockAccount(eth.accounts[0], 'PASSWORD');
44    var inputdata = ["pub", "h", "u", "sv", "signerid"];
45    var contract = web3.eth.contract(abi).new(inputdata,{ from: eth.accounts[0], data: code, gas: 1000000 });
46    web3.personal.lockAccount(eth.accounts[0]);
47    ```
48
49    - call the method in the contract
50    ```js
51    contract.name()
52    ```