diff --git a/README.rst b/README.rst index 4f08a58ee..e8da5d563 100644 --- a/README.rst +++ b/README.rst @@ -31,7 +31,7 @@ What does it currently do project `_ - Run a Python based P2P node - Interactive CLI for configuring node and inspecting blockchain -- Build, deploy, and run smart contracts +- Compile, test, deploy and run Smart Contracts written in Python or any smart contract in the ``.avm`` format - Runs smart contracts on the blockchain in a Python virtual machine - Very basic Wallet functionality (not fully tested, please do not use on mainnet) @@ -252,8 +252,13 @@ basic interactivity. np-prompt NEO cli. Type 'help' to get started - neo> state - Progress: 1054913 / 1237188 + neo> show state + Progress: 10926 / 11145 + Block-cache length 0 + Blocks since program start 0 + Time elapsed 0.02598465 mins + Blocks per min 0 + TPS: 0 neo> @@ -267,20 +272,36 @@ Let's query for a block in the current server by hash or by block index: np-prompt NEO cli. Type 'help' to get started - neo> block 122235 + neo> show block 122235 { + "hash": "0xf9d7bc6f337a6cbe124b92b90ad7b29e2628e78202ea2daa19ed93fdc779c0e6", + "size": 686, + "version": 0, + "previousblockhash": "0x1f262a0979d6da0eabaaf54252fb2508564a99fee642a77ff0773671fe5fddb9", + "merkleroot": "0x5d4f86734c2a53187aa96751b9180d69f85f9bd7875f2eb83a27666ad052ea1e", + "time": 1496920870, "index": 122235, - "script": "", - "merkleroot": "1d5a895ea34509a83becb5d2f9391018a3f59d670d94a2c3f8deb509a07464bd", - "previousblockhash": "98ae05cb68ab857659cc6c8379eb7ba68b57ef1f5317904c295341d82d0a1713", + "nonce": "7847dea9df7571c1", + "nextconsensus": "AdyQbbn6ENjqWDa5JNYMwN3ikNcA4JeZdk", + "script": { + "invocation": "40e5a7d23cb065308412d769ca2ba6dd974aa453d0c915c25a7d951488eaa6c4eff5bbe251f01725b959fb89e7dd631f7f41efd50897c466d75e8359154f6137bf402f690a98a44e5ecb22e7f20bb75bac40cac89f4805f4706ec9daf8e6ccc15def216d667423bb148e78db9461e288d7363f699741a0efb4c7c6c6dc902250cf3f4023ba2eb464aa8841cb2230c0f9f016a47c1e54e1f809da550743c33b0529b5996f4c5993a38bb73887e0b3fd7a093f6abd00d136048169a99cf34373560b8956408e816d0a0b018c348070da63f513b5b3332ef31914c420203b792f25048c1b8b397bc4bd47315be44491f7182be8aeca39035a2cd51a20da034820e5e1b5c0644052ce1cb6769e9dc9375ea96db8d538e6b2210a093c555f759ccf1d908f8c2fe3cf6236c4dade54ebca825a36e81049c7f4b149c1458c30b37460fc22581201f2", + "verification": "55210209e7fd41dfb5c2f8dc72eb30358ac100ea8c72da18847befe06eade68cebfcb9210327da12b5c40200e9f65569476bbff2218da4f32548ff43b6387ec1416a231ee821034ff5ceeac41acf22cd5ed2da17a6df4dd8358fcb2bfb1a43208ad0feaab2746b21026ce35b29147ad09e4afe4ec4a7319095f08198fa8babbe3c56e970b143528d2221038dddc06ce687677a53d54f096d2591ba2302068cf123c1f2d75c2dddc542557921039dafd8571a641058ccc832c5e2111ea39b09c0bde36050914384f7a48bce9bf92102d02b1873a0863cd042cc717da31cea0d7cf9db32b74d4c72c01b0011503e2e2257ae" + }, "tx": [ - "1d5a895ea34509a83becb5d2f9391018a3f59d670d94a2c3f8deb509a07464bd" - ], - "version": 0, - "time": 1479110368, - "hash": "74671375033f506325ef08d35632f74083cca564dc7ea6444c94d3b9dec3f61b", - "consensus data": 16070047272025254767, - "next_consensus": "59e75d652b5d3827bf04c165bbe9ef95cca4bf55" + { + "txid": "0x5d4f86734c2a53187aa96751b9180d69f85f9bd7875f2eb83a27666ad052ea1e", + "size": 10, + "type": "MinerTransaction", + "version": 0, + "attributes": [], + "vout": [], + "vin": [], + "sys_fee": "0", + "net_fee": "0", + "scripts": [], + "nonce": 3749016001 + } + ] } neo> @@ -330,22 +351,19 @@ Basic Wallet commands :: - create wallet {wallet_path} - open wallet {wallet_path} + wallet create {wallet_path} + wallet open {wallet_path} wallet close wallet (verbose) wallet rebuild (start block) - wallet create_addr {number of addresses} - wallet delete_addr {addr} - - export wif {address} - import wif {wif} - - export nep2 {address} - import nep2 {nep2_encrypted_key} - - send {assetId or name} {address} {amount} (--from-addr={addr}) (--fee={priority_fee}) (--owners=[{addr}, ...]) (--tx-attr=[{"usage": ,"data":""}, ...]) + + wallet import wif {wif} + wallet export wif {address} + + wallet send {args} # (NEO/GAS) + wallet token send {args} # NEP5 + For a complete list of commands use ``help``. @@ -384,7 +402,6 @@ Logging Currently, ``np-prompt`` logs to ``prompt.log`` --------------- Tests ----- diff --git a/docs/source/example/sample2.avm b/docs/source/example/sample2.avm index 1fb46b42b..9a52599dc 100644 Binary files a/docs/source/example/sample2.avm and b/docs/source/example/sample2.avm differ diff --git a/docs/source/example/sample3.avm b/docs/source/example/sample3.avm index 7ec40f880..a4d4023e2 100644 Binary files a/docs/source/example/sample3.avm and b/docs/source/example/sample3.avm differ diff --git a/docs/source/neo/SmartContract/application-vs-verification.rst b/docs/source/neo/SmartContract/application-vs-verification.rst index 598b81eda..4591951e2 100644 --- a/docs/source/neo/SmartContract/application-vs-verification.rst +++ b/docs/source/neo/SmartContract/application-vs-verification.rst @@ -2,8 +2,8 @@ Application vs. Verification ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Now that you have built, tested, and testinvoked your SC, you may be asking, what is this ``Verification`` step, and how do I programatically interact with it? -Lets start out with our example from before of tracking a balance, and restrict it so that only an 'owner' address can perform operations on it. Heres the Smart Contract code: +Now that you have built, tested, and test invoked your SC, you may be asking, what is this ``Verification`` step, and how do I programmatically interact with it? +Lets start out with our example from before of tracking a balance, and restrict it so that only an 'owner' address can perform operations on it. Here's the Smart Contract code: .. code-block:: python @@ -18,7 +18,7 @@ Lets start out with our example from before of tracking a balance, and restrict print("Running Sample v4") trigger = GetTrigger() - # This determines that the SC is runnning in Verification mode + # This determines that the SC is running in Verification mode # This determines whether the TX will be relayed to the rest of the network # The `Verification` portion of SC is *read-only*, so calls to `Storage.Put` will fail. # You can, however, use `Storage.Get` @@ -81,7 +81,7 @@ We will turn on ``sc-events`` to make sure we can see exactly what is going on. .. code-block:: sh neo> - neo> build docs/source/neo/example/sample4.py test 070202 02 True False add AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 7 + neo> sc build_run docs/source/neo/example/sample4.py True False False 070202 02 add AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 7 Saved output to docs/source/neo/example/sample4.avm [I 180303 08:25:12 EventHub:71] [test_mode][SmartContract.Contract.Create] [562d6c29209dc96432c6868621fe489cedd05222] ['{\n "version": 0,\n "code": {\n "hash": "0x562d6c29209dc96432c6868621fe489cedd05222",\n "script": "0122c56b6a00527ac46a51527ac46a52527ac4140319e029b925857790e41785be9ccec6cab198966a53527ac41152756e6e696e672053616d706c65207634680f4e656f2e52756e74696d652e4c6f6768164e656f2e52756e74696d652e47657454726967676572616a54527ac46a54c301009c6492001552756e6e696e6720566572696669636174696f6e21680f4e656f2e52756e74696d652e4c6f676a53c368184e656f2e52756e74696d652e436865636b5769746e657373616a55527ac46a55c3642200094973204f776e657221680f4e656f2e52756e74696d652e4c6f67516c756661094e6f74204f776e6572680f4e656f2e52756e74696d652e4c6f67006c7566616a54c301109c6454011452756e6e696e67204170706c69636174696f6e21680f4e656f2e52756e74696d652e4c6f676a51c3652d01632a00114e6f742056616c69642041646472657373680f4e656f2e52756e74696d652e4c6f67006c75666168164e656f2e53746f726167652e476574436f6e74657874616a56527ac46a00c3036164649c6450006a56c36a51c37c680f4e656f2e53746f726167652e476574616a57527ac46a57c36a52c3936a58527ac46a56c36a51c36a58c35272680f4e656f2e53746f726167652e507574616a58c36c7566616a00c30672656d6f76659c644c006a56c36a51c37c680f4e656f2e53746f726167652e476574616a57527ac46a56c36a51c36a57c36a52c3945272680f4e656f2e53746f726167652e507574616a57c36a52c3946c7566616a00c30762616c616e63659c641f006a56c36a51c37c680f4e656f2e53746f726167652e476574616c756661006c756656c56b6a00527ac46a00c3c001149c640700516c756661006c7566",\n "parameters": "070202",\n "returntype": 2\n },\n "name": "test",\n "code_version": "test",\n "author": "test",\n "email": "test",\n "description": "test",\n "properties": {\n "storage": true,\n "dynamic_invoke": false\n }\n}'] [I 180303 08:25:12 EventHub:71] [test_mode][SmartContract.Runtime.Log] [562d6c29209dc96432c6868621fe489cedd05222] [b'Running Sample v4'] @@ -107,7 +107,7 @@ Currently, in order to interact with the ``Verification`` stage of the Smart Con .. code-block:: sh - neo> contract 2e80ee491a0a54c9bbb0f791672050f9ab367767 + neo> show contract 2e80ee491a0a54c9bbb0f791672050f9ab367767 { "version": 0, "code": { @@ -133,7 +133,7 @@ Lets test invoke again. .. code-block:: sh - neo> testinvoke 0x2e80ee491a0a54c9bbb0f791672050f9ab367767 add AMUUgxnLhGxNSATinNp8gKmndqM1BxDZHR 42 + neo> sc invoke 0x2e80ee491a0a54c9bbb0f791672050f9ab367767 add AMUUgxnLhGxNSATinNp8gKmndqM1BxDZHR 42 [I 180303 09:08:14 EventHub:71] [test_mode][SmartContract.Runtime.Log] [2e80ee491a0a54c9bbb0f791672050f9ab367767] [b'Running Sample v4'] [I 180303 09:08:14 EventHub:71] [test_mode][SmartContract.Runtime.Log] [2e80ee491a0a54c9bbb0f791672050f9ab367767] [b'\x10'] [I 180303 09:08:14 EventHub:71] [test_mode][SmartContract.Runtime.Log] [2e80ee491a0a54c9bbb0f791672050f9ab367767] [b'Running Application!'] diff --git a/docs/source/neo/SmartContract/smartcontracts.rst b/docs/source/neo/SmartContract/smartcontracts.rst index 22fa766c9..9ff32702a 100644 --- a/docs/source/neo/SmartContract/smartcontracts.rst +++ b/docs/source/neo/SmartContract/smartcontracts.rst @@ -149,7 +149,7 @@ This is sample1.py: .. code-block:: sh - neo> build docs/source/example/sample1.py + neo> sc build docs/source/example/sample1.py Saved output to docs/source/example/sample1.avm This command simply compiles the file and nothing else. You could now use the compiled ``.avm`` file to import in a later stage, or use another tool such as NEO-Gui to import your contract. @@ -162,32 +162,32 @@ Build and test is a much more useful command, since it allows you to not only co View ContractParameterType list :ref:`ContractParameterTypes` -The general syntax goes like this: ``build path/to/file.py test {input_params} {return_type} {needs_storage} {needs_dynamic_invoke} {is_payable} param1 param2 etc..`` where ``{input_params}`` and ``{return_type}`` +The general syntax goes like this: ``sc build_run {path} {storage} {dynamic_invoke} {payable} {params} {return type} {inputs} (--no-parse-addr) (--from-addr) (--owners) (--tx-attr)`` -- ``{input_params}`` is a single or series of ``ContractParameterType``, eg ``0710`` for an SC accepting a string and a list +- ``{storage}`` is a boolean, either ``True`` or ``False`` used to indicate whether or not the SC uses the ``Storage.Get/Put/Delete`` interop API +- ``{dynamic_invoke}`` is a boolean, indicating whether or not the SC will be calling another contract whose address it will not know until runtime. This will almost always be ``False`` +- ``{payable}`` is a boolean indicating whether the contract accepts NEO/GAS transfers to it (generally only used for ICO contracts) +- ``{params}`` define the argument types of the smart contract entry point. This is a single or series of ``ContractParameterType``'s, eg ``0710`` for an SC accepting a string and a list - ``{return_type}`` is a single ``ContractParameterType``, eg ``02`` for an SC returning an integer -- ``{needs_storage}`` is a boolean, either ``True`` or ``False`` used to indicate whether or not the SC uses the ``Storage.Get/Put/Delete`` interop API -- ``{needs_dynamic_invoke}`` is a boolean, indicating whether or not the SC will be calling another contract whose address it will not know until runtime. This will most always be ``False`` -- ``{is_payable}`` is a boolean indicating whether the contract accepts NEO/GAS transfers to it (generally only used for ICO's contracts) -- ``params1 params2 etc...`` These are the parameters you are testing with. +- ``inputs`` These are the actual parameters fed to the smart contract. -So for building and testing our ``sample1.py``, the syntax would be ``build docs/source/example/sample1.py test '' 01 False False``, where ``''`` indicates that no parameters are accepted and ``01`` indicates that it returns a boolean. Lets try it out in the propmt +So for building and testing our ``sample1.py``, the syntax would be ``sc build_run docs/source/example/sample1.py False False False '' 01 ``, where the first ``''`` indicates that no parameters are accepted, ``01`` indicates that it returns a boolean and the final ``''`` is the empty list of ``inputs``. Lets try it out in the prompt .. code-block:: sh - neo> build docs/source/example/sample1.py test '' 01 False False False + neo> sc build_run docs/source/example/sample1.py False False False '' 01 '' Saved output to docs/source/example/sample1.avm - please open a wallet to test built contract + Please open a wallet to test built contract neo> Ok, so it looks like we will need to open a wallet to test our contract! Note that after you open your wallet, you can use the up arrow key to select the previous command you entered. .. code-block:: sh - neo> open wallet Wallets/awesome + neo> wallet open Wallets/awesome [password]> *********** Opened wallet at Wallets/awesome - neo> build docs/source/example/sample1.py test '' 01 False False False + neo> sc build_run docs/source/example/sample1.py False False False '' 01 '' Saved output to docs/source/example/sample1.avm [I 180302 22:22:58 Invoke:482] Used 0.016 Gas @@ -205,7 +205,7 @@ And you have now built and tested your first SC. If you would like to view the .. code-block:: sh - neo> build docs/source/example/sample1.py test '' 02 False False False + neo> sc build docs/source/example/sample1.py False False False '' 02 '' Saved output to docs/source/example/sample1.avm [I 180302 22:25:09 Invoke:482] Used 0.016 Gas @@ -226,7 +226,7 @@ You may have noticed that even though there is a ``print`` command in the contra neo> neo> config sc-events on Smart contract event logging is now enabled - neo> build docs/source/example/sample1.py test '' 01 False False False + neo> sc build_run docs/source/example/sample1.py False False False '' 01 '' Saved output to docs/source/example/sample1.avm [I 180302 22:56:19 EventHub:71] [test_mode][SmartContract.Contract.Create] [09a129673c61917593cb4b57dce066688f539d15] ['{\n "version": 0,\n "code": {\n "hash": "0x09a129673c61917593cb4b57dce066688f539d15",\n "script": "54c56b0b48656c6c6f20576f726c64680f4e656f2e52756e74696d652e4c6f67516c7566",\n "parameters": "",\n "returntype": 1\n },\n "name": "test",\n "code_version": "test",\n "author": "test",\n "email": "test",\n "description": "test",\n "properties": {\n "storage": false,\n "dynamic_invoke": false\n }\n}'] [I 180302 22:56:19 EventHub:71] [test_mode][SmartContract.Runtime.Log] [09a129673c61917593cb4b57dce066688f539d15] [b'Hello World'] @@ -272,30 +272,11 @@ Ok now lets try a little more complex contract, detailed here as `sample2.py` else: return -1 -We will build and run with a few paramaters: +We will build and run with a few parameters: .. code-block:: sh - neo> build docs/source/example/sample2.py test 070202 02 False False False - Saved output to docs/source/example/sample2.avm - [E 180302 22:30:01 ExecutionEngine:825] COULD NOT EXECUTE OP: Invalid list operation b'z' ROLL - [E 180302 22:30:01 ExecutionEngine:826] Invalid list operation - Traceback (most recent call last): - File "/Users/thomassaunders/Workshop/neo-python/neo/VM/ExecutionEngine.py", line 823, in StepInto - self.ExecuteOp(op, self.CurrentContext) - File "/Users/thomassaunders/Workshop/neo-python/neo/VM/ExecutionEngine.py", line 276, in ExecuteOp - estack.PushT(estack.Remove(n)) - File "/Users/thomassaunders/Workshop/neo-python/neo/VM/RandomAccessStack.py", line 57, in Remove - raise Exception("Invalid list operation") - Exception: Invalid list operation - [I 180302 22:30:01 InteropService:93] Trying to get big integer Array: ['None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None'] - - -Oh no, what happened there! Oh, it looks like we tried to test a contract that wanted some parameters but didn't supply them. Note than if you're building and testing contracts and you see an error similar to this, that is probably the issue you are running into. Lets try that again with some parameters. - -.. code-block:: sh - - neo> build docs/source/example/sample2.py test 070202 02 False False False add 1 2 + neo> sc build_run docs/source/example/sample2.py False False False 070202 02 add 1 2 Saved output to docs/source/example/sample2.avm [I 180302 22:32:06 Invoke:482] Used 0.033 Gas @@ -308,7 +289,7 @@ Oh no, what happened there! Oh, it looks like we tried to test a contract that ------------------------------------------------------------- neo> - neo> build docs/source/example/sample2.py test 070202 02 False False False mul -1 20000 + neo> sc build_run docs/source/example/sample2.py False False False 070202 02 mul -1 20000 Saved output to docs/source/example/sample2.avm [I 180302 22:33:36 Invoke:482] Used 0.041 Gas @@ -366,7 +347,7 @@ You will also notice that we are using ``True`` to indicate that we are using th .. code-block:: sh - neo> build docs/source/example/sample3.py test 070502 02 True False False add AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 3 + neo> sc build_run docs/source/example/sample3.py True False False 070502 02 add AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 3 Saved output to docs/source/example/sample3.avm [I 180302 23:04:33 Invoke:482] Used 1.174 Gas @@ -384,7 +365,7 @@ Invoke again and you will see that our test invokes persist the values in storag .. code-block:: sh - neo> build docs/source/example/sample3.py test 070502 02 True False False add AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 3 + neo> sc build_run docs/source/example/sample3.py True False False 070502 02 add AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 3 Saved output to docs/source/example/sample3.avm [I 180302 23:04:33 Invoke:482] Used 1.174 Gas @@ -402,7 +383,7 @@ Now remove some value .. code-block:: sh - neo> build docs/source/example/sample3.py test 070502 02 True False False remove AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 2 + neo> sc build_run docs/source/example/sample3.py True False False 070502 02 remove AG4GfwjnvydAZodm4xEDivguCtjCFzLcJy 2 Saved output to docs/source/example/sample3.avm [I 180302 23:09:21 Invoke:482] Used 1.176 Gas @@ -420,7 +401,7 @@ You can also pass in a ByteArray object for the address, and test that the ``is_ .. code-block:: sh - neo> build docs/source/example/sample3.py test 070502 02 True False False add bytearray(b'\x00\x01\x02\x03') 4 + neo> sc build_run docs/source/example/sample3.py True False False 070502 02 add bytearray(b'\x00\x01\x02\x03') 4 Saved output to docs/source/example/sample3.avm [I 180302 23:12:43 Invoke:482] Used 0.041 Gas @@ -438,7 +419,7 @@ Note that sending in the readable format of the address ( *AG4GfwjnvydAZodm4xEDi .. code-block:: sh - neo> build docs/source/example/sample3.py test 070502 02 True False False balance bytearray(b'\x03\x19\xe0)\xb9%\x85w\x90\xe4\x17\x85\xbe\x9c\xce\xc6\xca\xb1\x98\x96') 0 + neo> sc build_run docs/source/example/sample3.py True False False 070502 02 balance bytearray(b'\x03\x19\xe0)\xb9%\x85w\x90\xe4\x17\x85\xbe\x9c\xce\xc6\xca\xb1\x98\x96') 0 Saved output to docs/source/example/sample3.avm [I 180302 23:16:23 Invoke:482] Used 0.162 Gas @@ -455,15 +436,29 @@ Note that sending in the readable format of the address ( *AG4GfwjnvydAZodm4xEDi Hopefully this is enough to get you started with building and testing your Smart Contracts in the ``neo-python`` prompt. -Importing a Smart Contract +Deploying a Smart Contract ^^^^^^^^^^^^^^^^^^^^^^^^^^ -Smart Contract importing is somewhat similar to the ``build .. test`` notation, though you do not need to send any parameters along with it. The format is ``import contract path/to/sample2.avm {input_params} {return_type} {needs_storage} {needs_dynamic_invoke}``. After running this command, if everything goes ok you will be prompted to add some metadata about the contract. Once that is complete, you will then have the choice to actually deploy this Smart Contract on the network. Beware that doing so will cost you some Gas! +Smart Contract deployment is somewhat similar to the ``sc build_run`` notation, though you do not need to send any parameters along with it. + +.. code-block:: sh + + Usage: sc deploy {path} {storage} {dynamic_invoke} {payable} {params} (returntype) + + path - path to the desired Python (.py) file + storage - boolean input to determine if smart contract requires storage + dynamic_invoke - boolean input to determine if smart contract requires dynamic invoke + payable - boolean input to determine if smart contract is payable + params - input parameter types of the smart contract + returntype - (Optional) the return type of the smart contract output + +After running this command, if everything goes ok you will be prompted to add some metadata about the contract. Once that is complete, you will then have the choice to actually send this Smart Contract to the network. Beware that doing so will cost you some Gas! + .. code-block:: sh neo> - neo> import contract docs/source/example/sample2.avm 070202 02 False False False + neo> sc deploy docs/source/example/sample2.avm False False False 070202 02 Please fill out the following contract details: [Contract Name] > Sample Calculator [Contract Version] > .01 @@ -512,7 +507,7 @@ Now you have deployed your contract to the network. If all goes well, it will so .. code-block:: sh - neo> tx f8ad261d28bf4bc5544e47f9bc3fff85f85ee674f14162dac81dd56bf73cf0a3 + neo> show tx f8ad261d28bf4bc5544e47f9bc3fff85f85ee674f14162dac81dd56bf73cf0a3 { "txid": "0xf8ad261d28bf4bc5544e47f9bc3fff85f85ee674f14162dac81dd56bf73cf0a3", "type": "InvocationTransaction", @@ -520,15 +515,19 @@ Now you have deployed your contract to the network. If all goes well, it will so "attributes": [], [ MORE Output Omitted ] - neo> contract 0x86d58778c8d29e03182f38369f0d97782d303cc0 + neo> show contract 0x86d58778c8d29e03182f38369f0d97782d303cc0 { "version": 0, "code": { "hash": "0x86d58778c8d29e03182f38369f0d97782d303cc0", "script": "5ec56b6a00527ac46a51527ac46a52527ac46a00c3036164649c640d006a51c36a52c3936c7566616a00c3037375629c640d006a51c36a52c3946c7566616a00c3036d756c9c640d006a51c36a52c3956c7566616a00c3036469769c640d006a51c36a52c3966c7566614f6c7566006c7566", - "parameters": "070202", - "returntype": 2 - }, + } + "parameters": [ + "String", + "Integer", + "Integer" + ], + "returntype": "Integer", "name": "A test calculator contract", "code_version": ".01", "author": "tom@cityofzion.io", @@ -548,13 +547,13 @@ Now that you have deployed the contract on the network, you can interact with it Test Invoke Your Contracts ^^^^^^^^^^^^^^^^^^^^^^^^^^ -Once the contract is deployed, you can no longer interact and change and build it like you can with the ``build .. test`` command, but it is best to do ``testinvoke`` in order to determine how things work on the chain. +Once the contract is deployed, you can no longer interact and change and build it like you can with the ``sc build_run`` command, but it is best to do ``sc invoke`` in order to determine how things work on the chain. -Now that we have deployed the *Calculator Contract* we can interact with it with the ``testinvoke`` command, as long as we know its script hash. The syntax is ``testinvoke {contract_hash} param1 param2 .. etc`` +Now that we have deployed the *Calculator Contract* we can interact with it with the ``testinvoke`` command, as long as we know its script hash. The syntax is ``sc invoke {contract_hash} {inputs} {optional args}`` .. code-block:: sh - neo> testinvoke 0x86d58778c8d29e03182f38369f0d97782d303cc0 add 1 2 + neo> sc invoke 0x86d58778c8d29e03182f38369f0d97782d303cc0 add 1 2 Used 0.033 Gas ------------------------------------------------------------------------------------------------------------------------------------- @@ -582,7 +581,7 @@ Once again, this invoke is only done locally. It will not be run on the network neo> config sc-events on Smart contract event logging is now enabled neo> - neo> testinvoke 0x86d58778c8d29e03182f38369f0d97782d303cc0 add 1 2 + neo> sc invoke 0x86d58778c8d29e03182f38369f0d97782d303cc0 add 1 2 [I 180303 07:38:58 EventHub:71] [test_mode][SmartContract.Execution.Success] [86d58778c8d29e03182f38369f0d97782d303cc0] [3] Used 0.033 Gas diff --git a/docs/source/overview.rst b/docs/source/overview.rst index c0cf4336a..518ee13b6 100644 --- a/docs/source/overview.rst +++ b/docs/source/overview.rst @@ -8,7 +8,7 @@ What does it currently do - This project aims to be a full port of the original C# `NEO project `_ - Run a Python based P2P node - Interactive CLI for configuring node and inspecting blockchain -- Compile, test, deploy and run Smart Contracts written in python or any Smart Contract in the ``.avm format`` +- Compile, test, deploy and run Smart Contracts written in python or any Smart Contract in the ``.avm`` format - `NEP2 `_ and `NEP5 `_ compliant wallet functionality - RPC Client - RPC server diff --git a/docs/source/prompt.rst b/docs/source/prompt.rst index 8acc7587b..9e8986802 100644 --- a/docs/source/prompt.rst +++ b/docs/source/prompt.rst @@ -22,7 +22,7 @@ Create a wallet .. code-block:: sh - neo> create wallet path/to/walletfile + neo> wallet create path/to/walletfile [Password 1]> ********** [Password 2]> ********** Wallet { @@ -52,7 +52,7 @@ Open a wallet .. code-block:: sh - neo> open wallet path/to/walletfile + neo> wallet open path/to/walletfile [Password]> *********** Opened wallet at path/to/walletfile neo> @@ -95,19 +95,9 @@ If your wallet is behaving unexepectedly or you have imported a new address into restarting at 700000 neo> -Migrate your wallet -^^^^^^^^^^^^^^^^^^^ -If there have been changes to the wallet data model, you may need to migrate your wallet -.. code-block:: sh - - neo> wallet migrated - migrated wallet - neo> - - -Reencrypt your wallet -^^^^^^^^^^^^^^^^^^^^^ +Re-encrypt your wallet +^^^^^^^^^^^^^^^^^^^^^^ If you get a message like this when opening your wallet, you must reencrypt in order to secure against previous wallet vulnerabilities. .. code-block:: sh @@ -128,7 +118,7 @@ You may want to import a `WIF ` .. code-block:: sh - neo> import wif KxP97gujib35PBEnTq78e5NmYVbeaosU4AdguDzZ4tyf6a7W32UM + neo> wallet import wif KxP97gujib35PBEnTq78e5NmYVbeaosU4AdguDzZ4tyf6a7W32UM Imported key KxP97gujib35PBEnTq78e5NmYVbeaosU4AdguDzZ4tyf6a7W32UM Pubkey: 303263383231666338336465373331313039633435653034346136353863386631313337623730303461396232323237613335653262353566613061313630323731 neo> @@ -139,7 +129,7 @@ You may want to export a `WIF ` .. code-block:: sh - neo> export wif AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK + neo> wallet export wif AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK [Wallet Password]> *********** WIF key export: KxP97gujib35PBEnTq78e5NmYVbeaosU4AdguDzZ4tyf6a7W32UM neo> @@ -151,7 +141,7 @@ You can import a `NEP2 import nep2 6PYVPVe1fQznphjbUxXP9KZJqPMVnVwCx5s5pr5axRJ8uHkMtZg97eT5kL + neo> wallet import nep2 6PYVPVe1fQznphjbUxXP9KZJqPMVnVwCx5s5pr5axRJ8uHkMtZg97eT5kL [Key Password]> ****************** Imported nep2 key: 6PYVPVe1fQznphjbUxXP9KZJqPMVnVwCx5s5pr5axRJ8uHkMtZg97eT5kL Pubkey: 303236323431653765323662333862623731353462386164343934353862393766623163343739373434336463393231633563613537373466353131613262626663 @@ -163,7 +153,7 @@ You can export an address as `NEP2 export nep2 AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt + neo> wallet export nep2 AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt [Wallet Password]> *********** [Key Password 1]> ****************** [Key Password 2]> ****************** @@ -176,7 +166,7 @@ Delete address .. code-block:: sh - neo> wallet delete_addr AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt + neo> wallet address delete AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt Deleted address AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt neo> @@ -187,7 +177,7 @@ A **watch only** address is any address that you do not have the public key for .. code-block:: sh - neo> import watch_addr AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt + neo> wallet import watch_addr AStZHy8E6StCqYQbzMqi4poH7YNDHQKxvt neo> @@ -200,7 +190,7 @@ You may have a smart contract which has been deployed that you want to use funds .. code-block:: sh # import contract_addr {script_hash} {pubkey} - neo> import contract_addr 3c62006802d895974069a1d96398a04b4703f0f8 027973267230b7cba0724589653e667ddea7aa8479c01a82bf8dd398cec93508ef + neo> wallet import contract_addr 3c62006802d895974069a1d96398a04b4703f0f8 027973267230b7cba0724589653e667ddea7aa8479c01a82bf8dd398cec93508ef Added contract addres AeU8kTJxynwkT3q9ao8aDFuaRJBkU3AfFG to wallet neo> @@ -217,11 +207,13 @@ You may send assets from your wallet using the following command. Note that wit .. code-block:: sh # syntax send {asset_name} {address to} {amount} ( optional: --from-addr={from_addr}) - neo> send gas AeU8kTJxynwkT3q9ao8aDFuaRJBkU3AfFG 11 + neo> wallet send gas AeU8kTJxynwkT3q9ao8aDFuaRJBkU3AfFG 11 [Password]> *********** Relayed Tx: 468e294b11a9f65cc5e2c372124877472eebf121befb77ceed23a84862a606d3 neo> +Use ``wallet send help`` to view all required arguments and their descriptions. + Send From ^^^^^^^^^ @@ -231,12 +223,12 @@ You may also specify a particular address to send assets from. This is especiall .. code-block:: sh # syntax send {asset_name} {address to} {amount} ( optional: --from-addr={from_addr}) - neo> send gas AeU8kTJxynwkT3q9ao8aDFuaRJBkU3AfFG 11 --from-addr=AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK + neo> wallet send gas AeU8kTJxynwkT3q9ao8aDFuaRJBkU3AfFG 11 --from-addr=AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK [Password]> *********** Relayed Tx: a43dfb30af63bd0e5a510b05f02b3d40932af26d4564e040e3812ce78e76ce71 neo> - +Use ``wallet send help`` to view all required arguments and their descriptions. ----------- @@ -250,7 +242,7 @@ You may want to observe or interact with ``NEP5`` Tokens with your wallet. To d .. code-block:: sh - neo> import token f8d448b227991cf07cb96a6f9c0322437f1599b9 + neo> wallet import token f8d448b227991cf07cb96a6f9c0322437f1599b9 added token { "name": "NEP5 Standard", "script_hash": "f8d448b227991cf07cb96a6f9c0322437f1599b9", @@ -329,10 +321,17 @@ Next we create the multi signature address as follows. .. code-block:: sh - neo> import multisig_addr - please specify multisig contract like such: 'import multisig {pubkey in wallet} {minimum # of signatures required} {signing pubkey 1} {signing pubkey 2}...' + neo> wallet import multisig_addr help + + Import a multi-signature address + + Usage: wallet import multisig_addr {own pub key} {sign_cnt} {signing key n} + + own pub key - public key in your own wallet (use `wallet` to find the information) + sign_cnt - minimum number of signatures required for using the address (min is: 1) + signing key n - all remaining signing public keys - neo> import multisig_addr 037b8992e8384212f82e05c8836816c0f14dff9528397138731638b17d6357021e 1 037b8992e8384212f82e05c8836816c0f14dff9528397138731638b17d6357021e 02883118351f8f47107c83ab634dc7e4 + neo> wallet import multisig_addr 037b8992e8384212f82e05c8836816c0f14dff9528397138731638b17d6357021e 1 02883118351f8f47107c83ab634dc7e4 ffe29d274e7d3dcf70159c8935ff769beb [I 180310 16:49:19 UserWallet:191] contract does not exist yet Added multi-sig contract address ALXEKioZntX73QawcnfcHUDvTVm8qXjAxf to wallet @@ -389,7 +388,7 @@ Now that we can access the funds we can send them to our own address as follows .. code-block:: sh - neo> send NEO ANFLgwKG8Eni9gJmKfM7yFXEaWwoGkSUid 5 --from-addr=ALXEKioZntX73QawcnfcHUDvTVm8qXjAxf + neo> wallet send NEO ANFLgwKG8Eni9gJmKfM7yFXEaWwoGkSUid 5 --from-addr=ALXEKioZntX73QawcnfcHUDvTVm8qXjAxf [Password]> ********** [I 180310 17:02:42 Transaction:611] Verifying transaction: b'c32b0e3d9adbef6720abfad5106dcd2dacb17b31d4f9d32cbcf8ed6e7f566ef3' Relayed Tx: c32b0e3d9adbef6720abfad5106dcd2dacb17b31d4f9d32cbcf8ed6e7f566ef3