User Tools

Site Tools


blockchain

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
blockchain [2017/09/21 06:31] – created stephenblockchain [2017/12/01 01:19] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Blockchain ====== ====== Blockchain ======
 +
 +===== Links =====
 +
 +  * [[https://nethereum.readthedocs.io/en/latest/|Nethereum Documentation]]
 +  * [[https://github.com/ethereumjs/testrpc#usage|Testrpc command line options]]
 +  * [[https://stackoverflow.com/questions/47543679/how-do-i-compile-a-solidity-contract-with-an-import-to-standalone-byte-code|How do I compile a Solidity contract with an import to standalone byte code?]]
 +
 +===== General Notes =====
 +
 +  * Make sure the constructor of the contract has the correct access modifiers:
 +<code>
 +function MegaContract() public payable {
 +</code>
 +
 +==== Security ====
 +
 +To do anything that requires gas, either unlock the account beforehand with the password:
 +
 +<code>
 +var address = "...";
 +var password = "...";
 +var web3 = new Web3();
 +var unlockAccountResult = await web3.Personal.UnlockAccount.SendRequestAsync(address, password, 120);
 +Assert.IsTrue(unlockAccountResult);
 +</code>
 +
 +Or use the private key to create the Web3 object:
 +
 +<code>
 +var privateKey = "...";
 +var web3 = new Web3(new Account(privateKey));
 +</code>
 +
 +===== Questions =====
 +
 +  * [[https://stackoverflow.com/questions/47543679/how-do-i-compile-a-solidity-contract-with-an-import-to-standalone-byte-code|How do I compile a Solidity contract with an import to standalone byte code?]]
 +  * How to I get the result of calling an external function with Nethereum?
 +
 +===== Tool Set Install =====
 +
 +  - Metamask Chrome extension.
 +  - (Visual Studio Code)
 +  - NodeJS
 +  - [Admin PowerShell] ''<nowiki>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned</nowiki>''
 +  - Chocolately
 +  - [Admin PowerShell] ''<nowiki>choco install git -params "/GetAndUnixToolsOnPath"</nowiki>''
 +  - [Admin PowerShell] ''<nowiki>git config --system http.sslverify false</nowiki>''
 +  - [Admin PowerShell] ''<nowiki>npm install -g node-gyp</nowiki>''
 +  - [Admin PowerShell] ''<nowiki>npm install --global --production windows-build-tools</nowiki>''
 +  - [Admin PowerShell] ''<nowiki>npm install -g ethereumjs-testrpc</nowiki>''
 +  - [Admin PowerShell] ''<nowiki>npm install -g truffle</nowiki>''
 +
 +===== Commands =====
 +
 +| ''<nowiki>truffle init</nowiki>'' | Set up project. |
 +| ''<nowiki>testrpc</nowiki>'' | Start RPC. |
 +| ''<nowiki>truffle.cmd comp</nowiki>'' | Compile everything. |
 +| ''<nowiki>truffle.cmd migrate</nowiki>'' | Deploy everything. |
 +| ''<nowiki>truffle.cmd console</nowiki>'' | Console mode (to interact with contract). |
 +| [Truffle Console] ''<nowiki>var hw</nowiki>'' | Create a variable to reference our contract. |
 +| [Truffle Console] ''<nowiki>HelloWorld.deployed().then(function(deployed){hw=deployed;});</nowiki>'' | Get the reference (note that it is async). |
 +| [Truffle Console] ''<nowiki>hw.SayHello.call()</nowiki>'' | Call a **read-only** method on the contract. |
 +| [Truffle Console] ''<nowiki>hw.sendCoin('0x8...', 100)</nowiki>'' | Call a **modifying** method on the contract. |
 +| [Truffle Console] ''<nowiki>.exit</nowiki>'' | Exit console mode. |
 +
 +===== Implementations of Ethereum blockchange =====
 +
 +^ Implementation ^ Language ^ Pruning ^ Notes ^
 +| Geth | Go | Yes | |
 +| Parity | Rust | Yes | |
 +| EthereumJ | Java | Yes | |
 +| Eth | C++ | No | Reference implementation is meant for developers only. |
 +| PyEthApp | Python | No | |
 +
 +===== Glossary =====
 +
 +| ABI | Application Binary Interface. Is basically how you call functions in a contract and get data back. Like a WSDL or .h file in C. |
 +
 +===== VS Code =====
 +
 +Use the [[https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity|Solidity]] extension.
 +  * F5 - Compilation of the current contract 
 +  * Ctrl + F5 - Compilation of all the contracts
 +
 +===== Nethereum =====
 +
 +Start with [[https://www.nuget.org/packages/Nethereum.Web3/|Nethereum.Web3]].
 +
 +==== Tutorial ====
 +
 +Video is [[https://www.youtube.com/watch?v=4t5Z3eX59k4|here]].
 +
 +  - [VS Code] Write contract
 +  - [VS Code] Compile contract
 +  - [Command Line] Start Geth
 +  - [VS] Create unit test project.
 +  - [VS] NuGet install Nethereum.Web3 + dependencies.
 +
 +===== Dev VM =====
 +
 +Geth's encrypted accounts key store files can be found in ''%APPDATA%/Ethereum''.
 +
 +==== Run Geth ====
 +
 +  - Open a //separate// DOS ConEmu.
 +  - [ConEmu DOS] Run the command, ''C:\Users\TallGuy-DevVm\Dev\Geth\startgeth.bat''
 +  - Open a //separate// Admin PowerShell ConEmu.
 +  - [ConEmu PowerShell] Run the command, ''(Get-Process geth).PriorityClass = <nowiki>"BelowNormal"</nowiki>''
 +
  
blockchain.1505975497.txt.gz · Last modified: 2017/09/22 07:31 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki