====== 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: function MegaContract() public payable { ==== Security ==== To do anything that requires gas, either unlock the account beforehand with the password: var address = "..."; var password = "..."; var web3 = new Web3(); var unlockAccountResult = await web3.Personal.UnlockAccount.SendRequestAsync(address, password, 120); Assert.IsTrue(unlockAccountResult); Or use the private key to create the Web3 object: var privateKey = "..."; var web3 = new Web3(new Account(privateKey)); ===== 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] ''Set-ExecutionPolicy -ExecutionPolicy RemoteSigned'' - Chocolately - [Admin PowerShell] ''choco install git -params "/GetAndUnixToolsOnPath"'' - [Admin PowerShell] ''git config --system http.sslverify false'' - [Admin PowerShell] ''npm install -g node-gyp'' - [Admin PowerShell] ''npm install --global --production windows-build-tools'' - [Admin PowerShell] ''npm install -g ethereumjs-testrpc'' - [Admin PowerShell] ''npm install -g truffle'' ===== Commands ===== | ''truffle init'' | Set up project. | | ''testrpc'' | Start RPC. | | ''truffle.cmd comp'' | Compile everything. | | ''truffle.cmd migrate'' | Deploy everything. | | ''truffle.cmd console'' | Console mode (to interact with contract). | | [Truffle Console] ''var hw'' | Create a variable to reference our contract. | | [Truffle Console] ''HelloWorld.deployed().then(function(deployed){hw=deployed;});'' | Get the reference (note that it is async). | | [Truffle Console] ''hw.SayHello.call()'' | Call a **read-only** method on the contract. | | [Truffle Console] ''hw.sendCoin('0x8...', 100)'' | Call a **modifying** method on the contract. | | [Truffle Console] ''.exit'' | 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 = "BelowNormal"''