提交 528fc7a8 编写于 作者: B Bart Wyatt

merging changes to master @b1804199

......@@ -175,6 +175,7 @@ source ~/.bash_profile
## Building and running a node
### Getting the code
To download all of the code, download Eos and a recursion or two of submodules. The easiest way to get all of this is to do a recursive clone:
`git clone https://github.com/eosio/eos --recursive`
......@@ -359,7 +360,7 @@ code hash: 0000000000000000000000000000000000000000000000000000000000000000
With an account for a contract created, you can upload a sample contract:
```commandline
./eosc set contract currency ../../../contracts/currency/currency.wast ../../../contracts/currency/currency.abi
./eosc set contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi
```
As a response you should get a json with a `transaction_id` field. Your contract was successfully uploaded!
......@@ -507,5 +508,5 @@ curl http://127.0.0.1:8888/v1/chain/get_info
You can run the `eosc` commands via `docker exec` command. For example:
```
docker exec docker_eos_1 eosc contract exchange contracts/exchange/exchange.wast contracts/exchange/exchange.abi
docker exec docker_eos_1 eosc contract exchange build/contracts/exchange/exchange.wast build/contracts/exchange/exchange.abi
```
file(GLOB SOURCE_FILES "*.cpp")
add_wast_target(currency "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB ABI_FILES "*.abi")
add_wast_target(currency "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_BINARY_DIR})
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
\ No newline at end of file
......@@ -14,6 +14,8 @@
- [Transfer EOS](#transfereos)
- [Getting Transaction](#gettingtransaction)
- [Creating a Contract](#createcontract)
- [Pushing Message to Contract](#pushmessage)
- [Querying Contract](#querycontract)
- [Connecting to Particular Node](#particularnode)
- [Using Separate Wallet App](#separatewallet)
- [Skipping Signature](#skippingsignature)
......@@ -203,6 +205,15 @@
}
}
```
You can see that `tester` is now the controlled_account under `inita`
```
$ ./eosc get servants inita
{
"controlled_accounts": [
"tester"
]
}
```
@section transfereos Transfer EOS
......@@ -490,8 +501,59 @@
}
```
@section pushmessage Pushing Message to Contract
After the contract is published it initially allocates all of the currency to the `currency` account. So lets transfer some of it to our tester.
We can query the blockchain for the .abi of the contract, on which we can check the list of available actions and their respective message structure
```
$ ./eosc get code --a currency.abi currency
code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975
saving abi to currency.abi
$ cat currency.abi
{
"types": [{
"newTypeName": "AccountName",
"type": "Name"
}
],
"structs": [{
"name": "transfer",
"base": "",
"fields": {
"from": "AccountName",
"to": "AccountName",
"amount": "UInt64"
}
},{
"name": "account",
"base": "",
"fields": {
"account": "Name",
"balance": "UInt64"
}
}
],
"actions": [{
"action": "transfer",
"type": "transfer"
}
],
"tables": [{
"table": "account",
"indextype": "i64",
"keynames": [
"account"
],
"keytype": [],
"type": "account"
}
]
}
```
From the above abi, we can see that `currency` contract accepts an action called `transfer` that accepts message with fields `from`, `to`, and `amount`.
```
$ ./eosc push message currency transfer '{"from":"currency","to":"tester","amount":50}' -S currency -S tester -p currency@active
1589302ms thread-0 main.cpp:271 operator() ] Converting argument to binary...
......@@ -540,18 +602,6 @@
}
}
```
We can check the balance of `tester` inside its scope, and see it has balance of 50
```
./eosc get table tester currency account
{
"rows": [{
"account": "account",
"balance": 50
}
],
"more": true
}
```
Now we can transfer it from `tester` to `inita` and require the permission of `tester`. This should drain the balance of `tester` to 0.
......@@ -626,6 +676,30 @@
[...snipped...]
```
@section querycontract Querying Contract
After doing the transfer action on `currency` contract, we can verify the amount of token held by each account by looking at `currency`'s `account` table.
This table is stored on the scope of each account instead of on `currency` scope.
```
$./eosc get table tester currency account
{
"rows": [],
"more": false
}
$./eosc get table inita currency account
{
"rows": [{
"account": "account",
"balance": 50
}
],
"more": true
}
```
@section particularnode Connecting to Particular Node
By default, `eosc` will connect to `eosd` running on localhost port 8888. You can connect to another `eosd` node by specifying its host and port.
......
file(GLOB SOURCE_FILES "*.cpp")
add_wast_target(exchange "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB ABI_FILES "*.abi")
add_wast_target(exchange "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_BINARY_DIR})
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_dependencies( exchange currency )
file(GLOB SOURCE_FILES "*.cpp")
add_wast_target(infinite "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_SOURCE_DIR})
add_wast_target(infinite "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_BINARY_DIR})
file(GLOB SOURCE_FILES "*.cpp")
add_wast_target(simpledb "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB ABI_FILES "*.abi")
add_wast_target(simpledb "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_BINARY_DIR})
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
file(GLOB SOURCE_FILES "*.cpp")
add_wast_target(social "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_SOURCE_DIR})
\ No newline at end of file
add_wast_target(social "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file
file(GLOB SOURCE_FILES "*.cpp")
add_wast_target(test_api "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_SOURCE_DIR})
add_wast_target(test_api "${SOURCE_FILES}" "${CMAKE_SOURCE_DIR}/contracts" ${CMAKE_CURRENT_BINARY_DIR})
......@@ -65,32 +65,80 @@ $(function() {
<p>Tool for sending transactions and querying state from eosd.
<a href="#details">More...</a></p>
<h1><a class="anchor" id="contents"></a>
Table of Contents</h1>
<ul>
<li><a href="#intro">Introduction to EOSC</a></li>
<li><a href="#createwallet">Creating a Wallet</a></li>
<li><a href="#importkey">Importing Key to Wallet</a></li>
<li><a href="#lockwallet">Locking and Unlocking Wallet</a></li>
<li><a href="#openwallet">Opening Wallet</a></li>
<li><a href="#createaccount">Creating an Account</a></li>
<li><a href="#transfereos">Transfer EOS</a></li>
<li><a href="#gettingtransaction">Getting Transaction</a></li>
<li><a href="#createcontract">Creating a Contract</a></li>
<li><a href="#pushmessage">Pushing Message to Contract</a></li>
<li><a href="#querycontract">Querying Contract</a></li>
<li><a href="#particularnode">Connecting to Particular Node</a></li>
<li><a href="#separatewallet">Using Separate Wallet App</a></li>
<li><a href="#skippingsignature">Skipping Signature</a></li>
<li><a href="#additionaldocumentation">Additional Documentation</a></li>
</ul>
<h1><a class="anchor" id="intro"></a>
Introduction to EOSC</h1>
<p><code>eosc</code> is a command line tool that interfaces with the REST api exposed by eosd. In order to use <code>eosc</code> you will need to have a local copy of <code>eosd</code> running and configured to load the 'eos::chain_api_plugin'.</p>
<p>As an easy way for developers to test functionality without dealing with keys, <code>eosd</code> can be run so that Transaction signatures are not required. ... ./eosd &ndash;skip-transaction-signatures ...</p>
<div class="fragment"><div class="line"><span class="preprocessor"># Plugin(s) to enable, may be specified multiple times</span></div><div class="line"> plugin = eos::producer_plugin</div><div class="line"> plugin = eos::chain_api_plugin</div></div><!-- fragment --><p>After starting <code>eosd</code> you should be able to query the current blockchain state like so:</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> info</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;head_block_num&quot;</span>: 25048,</div><div class="line"> <span class="stringliteral">&quot;last_irreversible_block_num&quot;</span>: 25027,</div><div class="line"> <span class="stringliteral">&quot;head_block_id&quot;</span>: <span class="stringliteral">&quot;000061d8ae49d6af614e02779e19261959f22d6d9f37906ed5db2dabd88be142&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;head_block_time&quot;</span>: <span class="stringliteral">&quot;2017-07-25T17:44:48&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;head_block_producer&quot;</span>: <span class="stringliteral">&quot;initi&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;recent_slots&quot;</span>: <span class="stringliteral">&quot;1110000000000000000000000000000000000000000000000000000000000011&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;participation_rate&quot;</span>: <span class="stringliteral">&quot;0.07812500000000000&quot;</span></div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="createaccount"></a>
<p>In order to sign transaction and push it to the blockchain, you will need to have the 'eos::wallet_api_plugin' loaded.</p>
<p>And in order to query account history and transaction, you will need to have the 'eos::account_history_api_plugin' loaded. </p><div class="fragment"><div class="line"><span class="preprocessor"># Plugin(s) to enable, may be specified multiple times</span></div><div class="line"> plugin = eos::producer_plugin</div><div class="line"> plugin = eos::chain_api_plugin</div><div class="line"> plugin = eos::wallet_api_plugin</div><div class="line"> plugin = eos::account_history_api_plugin</div></div><!-- fragment --><p>After starting <code>eosd</code> you should be able to query the current blockchain state like so:</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> info</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;head_block_num&quot;</span>: 25048,</div><div class="line"> <span class="stringliteral">&quot;last_irreversible_block_num&quot;</span>: 25027,</div><div class="line"> <span class="stringliteral">&quot;head_block_id&quot;</span>: <span class="stringliteral">&quot;000061d8ae49d6af614e02779e19261959f22d6d9f37906ed5db2dabd88be142&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;head_block_time&quot;</span>: <span class="stringliteral">&quot;2017-07-25T17:44:48&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;head_block_producer&quot;</span>: <span class="stringliteral">&quot;initi&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;recent_slots&quot;</span>: <span class="stringliteral">&quot;1110000000000000000000000000000000000000000000000000000000000011&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;participation_rate&quot;</span>: <span class="stringliteral">&quot;0.07812500000000000&quot;</span></div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="createwallet"></a>
Creating a Wallet</h1>
<p>Any transaction sent to the blockchain will need to be signed by the respective authority's private key. Before you will be able to sign the transaction, you will need a wallet to store and manage the private key. </p><div class="fragment"><div class="line">$ ./eosc wallet create</div><div class="line">Creating wallet: <span class="keywordflow">default</span></div><div class="line">Save password to use in the future to unlock <span class="keyword">this</span> wallet.</div><div class="line">Without password imported keys will not be retrievable.</div><div class="line"><span class="stringliteral">&quot;PW5JD9cw9YY288AXPvnbwUk5JK4Cy6YyZ83wzHcshu8F2akU9rRWE&quot;</span></div></div><!-- fragment --><p> This will create a wallet called 'default' inside <code>eos-walletd</code> and return a password that you can use to unlock your wallet in the future.</p>
<p>You can create multiple wallets by specifying unique name </p><div class="fragment"><div class="line">$ ./eosc wallet create -n second-wallet</div><div class="line">Creating wallet: second-wallet</div><div class="line">Save password to use in the future to unlock <span class="keyword">this</span> wallet.</div><div class="line">Without password imported keys will not be retrievable.</div><div class="line"><span class="stringliteral">&quot;PW5Ji6JUrLjhKAVn68nmacLxwhvtqUAV18J7iycZppsPKeoGGgBEw&quot;</span></div></div><!-- fragment --><p>And you will be see it in the list of your wallets </p><div class="fragment"><div class="line">$ ./eosc wallet list</div><div class="line">Wallets:</div><div class="line">[</div><div class="line"> <span class="stringliteral">&quot;default *&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;second-wallet *&quot;</span></div><div class="line">]</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>For any wallet operation, if you don't specify the name of the wallet, it will always resort to <code>default</code> wallet</dd></dl>
<h1><a class="anchor" id="importkey"></a>
Importing Key to Wallet</h1>
<p>Import the key that you want to use to sign the transaction to your wallet. The following will import key for genesis accounts (i.e. inita, initb, initc, ..., initu) </p><div class="fragment"><div class="line">$ ./eosc wallet <span class="keyword">import</span> 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3</div><div class="line">imported <span class="keyword">private</span> key <span class="keywordflow">for</span>: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV</div></div><!-- fragment --><p> You will then be able to see the list of imported private keys and their respective public key </p><div class="fragment"><div class="line">$ ./eosc wallet keys</div><div class="line">[[</div><div class="line"> <span class="stringliteral">&quot;EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3&quot;</span></div><div class="line"> ]</div><div class="line">]</div></div><!-- fragment --><h1><a class="anchor" id="lockwallet"></a>
Locking and Unlocking Wallet</h1>
<p>To keep your private key safe, lock your wallet </p><div class="fragment"><div class="line">$ ./eosc wallet lock -n second-wallet</div><div class="line">Locked: <span class="stringliteral">&#39;second-wallet&#39;</span></div></div><!-- fragment --><p> Notice that the locked wallet doesn't have * symbol in the list </p><div class="fragment"><div class="line">$ ./eosc wallet list</div><div class="line">Wallets:</div><div class="line">[</div><div class="line"> <span class="stringliteral">&quot;default *&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;second-wallet&quot;</span></div><div class="line">]</div></div><!-- fragment --><p> To unlock it specify the password you get when creating the wallet </p><div class="fragment"><div class="line">$ ./eosc wallet unlock -n second-wallet --password PW5Ji6JUrLjhKAVn68nmacLxwhvtqUAV18J7iycZppsPKeoGGgBEw</div><div class="line">Unlocked: <span class="stringliteral">&#39;second-wallet&#39;</span></div></div><!-- fragment --><h1><a class="anchor" id="openwallet"></a>
Opening Wallet</h1>
<p>All of the wallets data are store inside data_dir folder. When you restart your wallet app (in this case <code>eosd</code>), you will need to open the wallet so <code>eosc</code> can have access to it. </p><div class="fragment"><div class="line">$ ./eosc wallet list</div><div class="line">Wallets: []</div><div class="line">$ ./eosc wallet open</div><div class="line">Wallets: [</div><div class="line"> <span class="stringliteral">&quot;default&quot;</span></div><div class="line">]</div><div class="line">$ ./eosc wallet open -n second-wallet</div><div class="line">Wallets: [</div><div class="line"> <span class="stringliteral">&quot;default&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;second-wallet&quot;</span></div><div class="line">]</div></div><!-- fragment --> <dl class="section note"><dt>Note</dt><dd>The wallet is locked by default</dd></dl>
<h1><a class="anchor" id="createaccount"></a>
Creating an Account</h1>
<p>In order to create an account you will need two new keys: owener and active. You can ask eosc to create some keys for you:</p>
<p>In order to create an account you will need two new keys: owner and active. You can ask <code>eosc</code> to create some keys for you:</p>
<p>This will be your owner key, </p><div class="fragment"><div class="line">$ ./eosc create key</div><div class="line"><span class="keyword">public</span>: EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq</div><div class="line"><span class="keyword">private</span>: 5JKbLfCXgcafDQVwHMm3shHt6iRWgrr9adcmt6vX3FNjAEtJGaT</div></div><!-- fragment --><p>And this will be your active key, </p><div class="fragment"><div class="line">$ ./eosc create key</div><div class="line"><span class="keyword">public</span>: EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA</div><div class="line"><span class="keyword">private</span>: 5Hv22aPcjnENBv6X9o9nKGdkfrW44En6z4zJUt2PobAvbQXrT9z</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>eosc does not save the generated private key.</dd></dl>
<p>Next we will create the account <code>tester</code>, but because all accounts need to be created by an existing account we will ask the <code>inita</code> account to create <code>tester</code> using the owner and active keys created above. <code>inita</code> was specified in the genesis file.</p>
<p>Right now this requires eosd to be run with the <code>--skip-transaction-signatures</code> flag.</p>
<div class="fragment"><div class="line">$ ./eosc create account inita tester EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;6acd2ece68c4b86c1fa209c3989235063384020781f2c67bbb80bc8d540ca120&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: <span class="stringliteral">&quot;25217&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: <span class="stringliteral">&quot;2095475630&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-07-25T17:54:55&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;inita&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;newaccount&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: <span class="stringliteral">&quot;c9251a0000000000b44c5a2400000000010000000102bcca6347d828d4e1868b7dfa91692a16d5b20d0ee3d16a7ca2ddcc7f6dd03344010000010000000102bcca6347d828d4e1868b7dfa91692a16d5b20d0ee3d16a7ca2ddcc7f6dd03344010000010000000001c9251a000000000061d0640b000000000100010000000000000008454f5300000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>After creating the account we can view the current account status like so:</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> account tester</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;staked_balance&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;unstaking_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;last_unstaking_time&quot;</span>: <span class="stringliteral">&quot;1969-12-31T23:59:59&quot;</span></div><div class="line">}</div></div><!-- fragment --><p>You will note that there is no balance because almost all genesis EOS tokens are currently allocated to the <code>eos</code> account.</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> account <a class="code" href="namespaceeos.html">eos</a></div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos_balance&quot;</span>: <span class="stringliteral">&quot;8999999999998100&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;staked_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;unstaking_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;last_unstaking_time&quot;</span>: <span class="stringliteral">&quot;1969-12-31T23:59:59&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;abi&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;types&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;newTypeName&quot;</span>: <span class="stringliteral">&quot;AccountName&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;Name&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;structs&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;base&quot;</span>: <span class="stringliteral">&quot;&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;fields&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;AccountName&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;AccountName&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;amount&quot;</span>: <span class="stringliteral">&quot;UInt64&quot;</span></div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;actions&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;action&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;tables&quot;</span>: []</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>The <code>eos</code> account happens to have an ABI (Application Binary Interface) defined which provides meta-data to tools that want to interface with the <code>eos</code> contract.</dd></dl>
<p>We can fund our <code>tester</code> account via <code>eosc</code> with the following command:</p>
<div class="fragment"><div class="line">$ ./eosc transfer <a class="code" href="namespaceeos.html">eos</a> tester 1000</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;52b488d27ce1f72a2b29f22e5e1638fa5db5d7805565884e795733a15c6c2195&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: <span class="stringliteral">&quot;25298&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: <span class="stringliteral">&quot;1151709320&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-07-25T17:58:58&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;amount&quot;</span>: 1000</div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;e54d000000000000b44c5a2400000000e803000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>Now we can verify that the funds were received.</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> account tester</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos_balance&quot;</span>: 1000,</div><div class="line"> <span class="stringliteral">&quot;staked_balance&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;unstaking_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;last_unstaking_time&quot;</span>: <span class="stringliteral">&quot;1969-12-31T23:59:59&quot;</span></div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="createcontract"></a>
<p>In order to push transaction as <code>inita</code>, you first need to <a href="#importkey">import inita's private key to your wallet</a></p>
<p>Then create an account called tester </p><div class="fragment"><div class="line">$ ./eosc create account inita tester EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;6acd2ece68c4b86c1fa209c3989235063384020781f2c67bbb80bc8d540ca120&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: <span class="stringliteral">&quot;25217&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: <span class="stringliteral">&quot;2095475630&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-07-25T17:54:55&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;inita&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;newaccount&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: <span class="stringliteral">&quot;c9251a0000000000b44c5a2400000000010000000102bcca6347d828d4e1868b7dfa91692a16d5b20d0ee3d16a7ca2ddcc7f6dd03344010000010000000102bcca6347d828d4e1868b7dfa91692a16d5b20d0ee3d16a7ca2ddcc7f6dd03344010000010000000001c9251a000000000061d0640b000000000100010000000000000008454f5300000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> You can see that <code>tester</code> is now the controlled_account under <code>inita</code> </p><div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> servants inita</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;controlled_accounts&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ]</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="transfereos"></a>
Transfer EOS</h1>
<p>After creating the account we can view the current account status like so:</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> account tester</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;staked_balance&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;unstaking_balance&quot;</span>: 0,</div><div class="line"> <span class="stringliteral">&quot;last_unstaking_time&quot;</span>: <span class="stringliteral">&quot;1969-12-31T23:59:59&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permissions&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;active&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;parent&quot;</span>: <span class="stringliteral">&quot;owner&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;required_auth&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;threshold&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;keys&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;key&quot;</span>: <span class="stringliteral">&quot;EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;weight&quot;</span>: 1</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;accounts&quot;</span>: []</div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;owner&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;parent&quot;</span>: <span class="stringliteral">&quot;owner&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;required_auth&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;threshold&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;keys&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;key&quot;</span>: <span class="stringliteral">&quot;EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;weight&quot;</span>: 1</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;accounts&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ]</div><div class="line">}</div></div><!-- fragment --><p>You will note that there is no balance because almost all genesis EOS tokens are currently allocated to the <code>eos</code> account and genesis accounts.</p>
<div class="fragment"><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos_balance&quot;</span>: <span class="stringliteral">&quot;69000000.0000 EOS&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;staked_balance&quot;</span>: <span class="stringliteral">&quot;0.0000 EOS&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;unstaking_balance&quot;</span>: <span class="stringliteral">&quot;0.0000 EOS&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;last_unstaking_time&quot;</span>: <span class="stringliteral">&quot;1969-12-31T23:59:59&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permissions&quot;</span>: []</div><div class="line">}</div></div><!-- fragment --><p>Since we have the private key of the genesis accounts (i.e. inita, initb, initc, etc) in the wallet. We can fund our <code>tester</code> account via <code>eosc</code> through any of the genesis account with the following command:</p>
<div class="fragment"><div class="line">$ ./eosc transfer inita tester 1000</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 2206,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 221394282,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-09-05T08:03:58&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;1f22e64240e1e479eee6ccbbd79a29f1a6eb6020384b4cca1a958e7c708d3e562009ae6e60afac96f9a3b89d729a50cd5a7b5a7a647540ba1678831bf970e83312&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;amount&quot;</span>: 1000,</div><div class="line"> <span class="stringliteral">&quot;memo&quot;</span>: <span class="stringliteral">&quot;&quot;</span></div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;000000008040934b00000000c84267a1e80300000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>Now we can verify that the funds were received.</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> account tester</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos_balance&quot;</span>: <span class="stringliteral">&quot;0.1000 EOS&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;staked_balance&quot;</span>: <span class="stringliteral">&quot;0.0001 EOS&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;unstaking_balance&quot;</span>: <span class="stringliteral">&quot;0.0000 EOS&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;last_unstaking_time&quot;</span>: <span class="stringliteral">&quot;1969-12-31T23:59:59&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permissions&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;active&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;parent&quot;</span>: <span class="stringliteral">&quot;owner&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;required_auth&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;threshold&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;keys&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;key&quot;</span>: <span class="stringliteral">&quot;EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;weight&quot;</span>: 1</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;accounts&quot;</span>: []</div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;owner&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;parent&quot;</span>: <span class="stringliteral">&quot;owner&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;required_auth&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;threshold&quot;</span>: 1,</div><div class="line"> <span class="stringliteral">&quot;keys&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;key&quot;</span>: <span class="stringliteral">&quot;EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;weight&quot;</span>: 1</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;accounts&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ]</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="gettingtransaction"></a>
Getting Transaction</h1>
<p>With account_history_api_plugin loaded in <code>eosd</code>, we can query for particular transaction </p><div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> transaction eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 2206,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 221394282,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-09-05T08:03:58&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;1f22e64240e1e479eee6ccbbd79a29f1a6eb6020384b4cca1a958e7c708d3e562009ae6e60afac96f9a3b89d729a50cd5a7b5a7a647540ba1678831bf970e83312&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;amount&quot;</span>: 1000,</div><div class="line"> <span class="stringliteral">&quot;memo&quot;</span>: <span class="stringliteral">&quot;&quot;</span></div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;000000008040934b00000000c84267a1e80300000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> Also we can query list of transactions performed by certain account starting from recent one </p><div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> transactions inita</div><div class="line">[</div><div class="line"> {</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;eb4b94b72718a369af09eb2e7885b3f494dd1d8a20278a6634611d5edd76b703&quot;</span>,</div><div class="line"> ...</div><div class="line"> },</div><div class="line"> {</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;6acd2ece68c4b86c1fa209c3989235063384020781f2c67bbb80bc8d540ca120&quot;</span>,</div><div class="line"> ...</div><div class="line"> },</div><div class="line"> ...</div><div class="line">]</div></div><!-- fragment --><h1><a class="anchor" id="createcontract"></a>
Creating a Contract</h1>
<p>In this section we will use <code>eosc</code> to create and publish a currency contract. You can find the example currency contract in the <code>eos/contracts/currency</code> directory.</p>
<p>The first step is to create an account for currency. We will have the <code>tester</code> account create the <code>currency</code> account.</p>
<div class="fragment"><div class="line">$ ./eosc create account tester <a class="code" href="namespacecurrency.html">currency</a> EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA</div></div><!-- fragment --><p>The next step is to publish the contract (.wast) and its abi (.abi)</p>
<div class="fragment"><div class="line">$ ./eosc contract <a class="code" href="namespacecurrency.html">currency</a> ../../contracts/<a class="code" href="namespacecurrency.html">currency</a>/<a class="code" href="namespacecurrency.html">currency</a>.wast ../../contracts/<a class="code" href="namespacecurrency.html">currency</a>/<a class="code" href="namespacecurrency.html">currency</a>.abi</div><div class="line">Reading WAST...</div><div class="line">Assembling WASM...</div><div class="line">Publishing contract...</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;9990306e13f630a9c5436a5a0b6fb8fe2c7f3da2f342b4898a39c4a2c17dcdb3&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 1208,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 3058534156,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-08-24T18:29:52&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;setcode&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: <span class="stringliteral">&quot;00000079b822651d0000e8150061736d0100000001390a60017e0060037e7e7f017f60047e7e7f7f017f60017f0060057e7e7e7f7f017f60027f7f0060027f7f017f60027e7f0060000060027e7e00029d010a03656e7606617373657274000503656e76086c6f61645f693634000403656e76067072696e7469000003656e76067072696e746e000003656e76067072696e7473000303656e760b726561644d657373616765000603656e760a72656d6f76655f693634000103656e760b7265717569726541757468000003656e760d726571756972654e6f74696365000003656e760973746f72655f6936340002030706000007030809040401700000050301000107cc0107066d656d6f72790200205f5a4e33656f733133726571756972654e6f74696365454e535f344e616d6545000a1e5f5a4e33656f7331317265717569726541757468454e535f344e616d6545000b345f5a4e3863757272656e6379313273746f72654163636f756e74454e33656f73344e616d6545524b4e535f374163636f756e7445000c355f5a4e3863757272656e637932336170706c795f63757272656e63795f7472616e7366657245524b4e535f385472616e7366657245000d04696e6974000e056170706c79000f0a9d0d060600200010080b0600200010070b3400024020012903084200510d0020004280808080a8d7bee3082001411010091a0f0b20004280808080a8d7bee308200110061a0b8a0604017e027f047e017f4100410028020441206b2208360204200029030821052000290300210720002903102104411010042004100241c000100442808080c887d7c8b21d100341d00010042007100341e000100420051003200029030021052000290308100820051008200029030010072000290300210142002105423b210441f00021034200210603400240024002400240024020054206560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b420021052008420037031820082006370310200142808080c887d7c8b21d4280808080a8d7bee308200841106a411010011a200041086a2903002101423b210441f00021034200210603400240024002400240024020054206560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b2008200637030020084200370308200142808080c887d7c8b21d4280808080a8d7bee3082008411010011a200841186a2203290300200041106a22022903005a418001100020032003290300200229030022057d370300200520082903087c20055a41b00110002008200829030820022903007c370308200029030021050240024020032903004200510d0020054280808080a8d7bee308200841106a411010091a0c010b20054280808080a8d7bee308200841106a10061a0b200041086a290300210502400240200841086a2903004200510d0020054280808080a8d7bee3082008411010091a0c010b20054280808080a8d7bee308200810061a0b4100200841206a3602040b980303027f057e017f4100410028020441106b220736020442002103423b210241e00121014200210403400240024002400240024020034207560d0020012c00002200419f7f6a41ff017141194b0d01200041a0016a21000c020b420021052003420b580d020c030b200041ea016a41002000414f6a41ff01714105491b21000b2000ad42388642388721050b2005421f83200242ffffffff0f838621050b200141016a2101200342017c2103200520048421042002427b7c2202427a520d000b42002103423b210241f00021014200210603400240024002400240024020034206560d0020012c00002200419f7f6a41ff017141194b0d01200041a0016a21000c020b420021052003420b580d020c030b200041ea016a41002000414f6a41ff01714105491b21000b2000ad42388642388721050b2005421f83200242ffffffff0f838621050b200141016a2101200342017c2103200520068421062002427b7c2202427a520d000b2007428094ebdc033703082007200637030020044280808080a8d7bee3082007411010091a4100200741106a3602040bb10303027f047e017f4100410028020441206b220836020442002105423b210441e00121034200210603400240024002400240024020054207560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b024020062000520d0042002105423b210441f00121034200210603400240024002400240024020054207560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b20062001520d00200842003703102008420037030820084200370318200841086a4118100541174b4180021000200841086a100d0b4100200841206a3602040b0bff010b0041040b04200500000041100b2254686973206170706561727320746f2062652061207472616e73666572206f6620000041c0000b0220000041d0000b072066726f6d20000041e0000b0520746f20000041f0000b086163636f756e7400004180010b2c696e746567657220756e646572666c6f77207375627472616374696e6720746f6b656e2062616c616e6365000041b0010b26696e7465676572206f766572666c6f7720616464696e6720746f6b656e2062616c616e6365000041e0010b0963757272656e6379000041f0010b097472616e7366657200004180020b1e6d6573736167652073686f72746572207468616e2065787065637465640000fd02046e616d651006617373657274020000086c6f61645f693634050000000000067072696e74690100067072696e746e0100067072696e747301000b726561644d6573736167650200000a72656d6f76655f693634030000000b726571756972654175746801000d726571756972654e6f7469636501000973746f72655f6936340400000000205f5a4e33656f733133726571756972654e6f74696365454e535f344e616d65450101301e5f5a4e33656f7331317265717569726541757468454e535f344e616d6545010130345f5a4e3863757272656e6379313273746f72654163636f756e74454e33656f73344e616d6545524b4e535f374163636f756e74450201300131355f5a4e3863757272656e637932336170706c795f63757272656e63795f7472616e7366657245524b4e535f385472616e73666572450901300131013201330134013501360137013804696e69740801300131013201330134013501360137056170706c7909013001310132013301340135013601370138010b4163636f756e744e616d65044e616d6502087472616e7366657200030466726f6d0b4163636f756e744e616d6502746f0b4163636f756e744e616d65087175616e746974790655496e743634076163636f756e740002036b65790655496e7436340762616c616e63650655496e74363401000000b298e982a4087472616e736665720100000080bafac608076163636f756e74&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>After the contract is published it initially allocates all of the currency to the <code>currency</code> account. So lets transfer some of it to our tester.</p>
<div class="fragment"><div class="line">$ ./eosc push message <a class="code" href="namespacecurrency.html">currency</a> transfer <span class="stringliteral">&#39;{&quot;from&quot;:&quot;currency&quot;,&quot;to&quot;:&quot;tester&quot;,&quot;quantity&quot;:50}&#39;</span> -s <a class="code" href="namespacecurrency.html">currency</a> -s tester -p active@<a class="code" href="namespacecurrency.html">currency</a></div><div class="line">1589302ms thread-0 main.cpp:271 operator() ] Converting argument to binary...</div><div class="line">1589304ms thread-0 main.cpp:290 operator() ] Transaction result:</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;1c4911c0b277566dce4217edbbca0f688f7bdef761ed445ff31b31f286720057&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 1173,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 2184027244,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-08-24T18:28:07&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;quantity&quot;</span>: 50</div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;00000079b822651d00000000c84267a13200000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>eosc contains documentation for all of its commands. For a list of all commands known to eosc, simply run it with no arguments: </p><div class="fragment"><div class="line">$ ./eosc</div><div class="line">ERROR: RequiredError: Subcommand required</div><div class="line">Command Line Interface to Eos Daemon</div><div class="line">Usage: ./eosc [OPTIONS] SUBCOMMAND</div><div class="line"></div><div class="line">Options:</div><div class="line"> -h,--help Print <span class="keyword">this</span> help message and exit</div><div class="line"></div><div class="line">Subcommands:</div><div class="line"> create Create various items, on and off the blockchain</div><div class="line"> <span class="keyword">get</span> Retrieve various items and information from the blockchain</div><div class="line"> contract Create or update the contract on an account</div><div class="line"> transfer Transfer EOS from account to account</div><div class="line"> push Push arbitrary data to the blockchain</div></div><!-- fragment --><p> To get help with any particular subcommand, run it with no arguments as well: </p><div class="fragment"><div class="line">$ ./eosc create</div><div class="line">ERROR: RequiredError: Subcommand required</div><div class="line">Create various items, on and off the blockchain</div><div class="line">Usage: ./eosc create SUBCOMMAND</div><div class="line"></div><div class="line">Subcommands:</div><div class="line"> key Create a <span class="keyword">new</span> keypair and <a class="code" href="namespaceeos.html#a1df73defa04d39763089df7faa35a934">print</a> the <span class="keyword">public</span> and <span class="keyword">private</span> keys</div><div class="line"> account Create a <span class="keyword">new</span> account on the blockchain</div><div class="line">$ ./eosc create account</div><div class="line">ERROR: RequiredError: creator</div><div class="line">Create a <span class="keyword">new</span> account on the blockchain</div><div class="line">Usage: ./eosc create account creator name OwnerKey ActiveKey</div><div class="line"></div><div class="line">Positionals:</div><div class="line"> creator TEXT The name of the account creating the <span class="keyword">new</span> account</div><div class="line"> name TEXT The name of the <span class="keyword">new</span> account</div><div class="line"> OwnerKey TEXT The owner <span class="keyword">public</span> key <span class="keywordflow">for</span> the account</div><div class="line"> ActiveKey TEXT The active <span class="keyword">public</span> key <span class="keywordflow">for</span> the account</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>at this time the blockchain is not validating signatures so anyone can do anything provided if they simply declare the proper authority. In the future the declared authorities will direct the wallet on which keys to use to sign the transaction. Also future revisions of this API may automatically detect <code>scope</code> and <code>authorization</code> via a trial run of the contract.</dd></dl>
<p>Now we can transfer it from <code>tester</code> to <code>inita</code> and require the permission of <code>tester</code>. This should drain the balance of <code>tester</code> to 0.</p>
<div class="fragment"><div class="line">$ ./eosc push message <a class="code" href="namespacecurrency.html">currency</a> transfer <span class="stringliteral">&#39;{&quot;from&quot;:&quot;tester&quot;,&quot;to&quot;:&quot;inita&quot;,&quot;quantity&quot;:50}&#39;</span> -s inita -s tester -p tester@active</div><div class="line">3116153ms thread-0 main.cpp:271 operator() ] Converting argument to binary...</div><div class="line">3116154ms thread-0 main.cpp:290 operator() ] Transaction result:</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;56b9f0f3b9f43254af446c5dca02a6fcb24ebcdb506d7248947fd4d52a27972a&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 2882,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 1880685856,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-08-24T19:53:34&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;quantity&quot;</span>: 50</div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;00000000c84267a1000000008040934b3200000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>Now that <code>tester</code> has a balance of 0, if we attempt this transfer a second time it should fail:</p>
<div class="fragment"><div class="line">$ ./eosc push message <a class="code" href="namespacecurrency.html">currency</a> transfer <span class="stringliteral">&#39;{&quot;from&quot;:&quot;tester&quot;,&quot;to&quot;:&quot;inita&quot;,&quot;quantity&quot;:50}&#39;</span> -s inita -s tester -p tester@active</div><div class="line">3543610ms thread-0 main.cpp:271 operator() ] Converting argument to binary...</div><div class="line">3543615ms thread-0 main.cpp:311 main ] Failed with error: 10 assert_exception: Assert Exception</div><div class="line">status_code == 200: Error</div><div class="line">: 10 assert_exception: Assert Exception</div><div class="line">test: assertion failed: integer underflow subtracting token balance</div><div class="line"> {<span class="stringliteral">&quot;s&quot;</span>:<span class="stringliteral">&quot;integer underflow subtracting token balance&quot;</span>,<span class="stringliteral">&quot;ptr&quot;</span>:176}</div><div class="line"> thread-1 wasm_interface.cpp:248 assertnonei32i32</div><div class="line"></div><div class="line">[...snipped...]</div></div><!-- fragment --> </div><!-- contents -->
<p>The first step is to create an account for currency. We will have the <code>inita</code> account create the <code>currency</code> account. Ensure you have inita private key imported.</p>
<div class="fragment"><div class="line">$ ./eosc create account inita <a class="code" href="namespacecurrency.html">currency</a> EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA</div></div><!-- fragment --><p>The next step is to publish the contract (.wast) and its abi (.abi).</p>
<p>We will need currency active key in our wallet for this </p><div class="fragment"><div class="line">$ ./eosc <span class="keyword">import</span> 5Hv22aPcjnENBv6X9o9nKGdkfrW44En6z4zJUt2PobAvbQXrT9z</div><div class="line">imported <span class="keyword">private</span> key <span class="keywordflow">for</span>: EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA</div></div><!-- fragment --><p> Then proceed with setting the code</p>
<div class="fragment"><div class="line">$ ./eosc <span class="keyword">set</span> contract <a class="code" href="namespacecurrency.html">currency</a> ../../../contracts/<a class="code" href="namespacecurrency.html">currency</a>/<a class="code" href="namespacecurrency.html">currency</a>.wast ../../../contracts/<a class="code" href="namespacecurrency.html">currency</a>/<a class="code" href="namespacecurrency.html">currency</a>.abi</div><div class="line">Reading WAST...</div><div class="line">Assembling WASM...</div><div class="line">Publishing contract...</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;9990306e13f630a9c5436a5a0b6fb8fe2c7f3da2f342b4898a39c4a2c17dcdb3&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 1208,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 3058534156,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-08-24T18:29:52&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;eos&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;eos&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;setcode&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: <span class="stringliteral">&quot;00000079b822651d0000e8150061736d0100000001390a60017e0060037e7e7f017f60047e7e7f7f017f60017f0060057e7e7e7f7f017f60027f7f0060027f7f017f60027e7f0060000060027e7e00029d010a03656e7606617373657274000503656e76086c6f61645f693634000403656e76067072696e7469000003656e76067072696e746e000003656e76067072696e7473000303656e760b726561644d657373616765000603656e760a72656d6f76655f693634000103656e760b7265717569726541757468000003656e760d726571756972654e6f74696365000003656e760973746f72655f6936340002030706000007030809040401700000050301000107cc0107066d656d6f72790200205f5a4e33656f733133726571756972654e6f74696365454e535f344e616d6545000a1e5f5a4e33656f7331317265717569726541757468454e535f344e616d6545000b345f5a4e3863757272656e6379313273746f72654163636f756e74454e33656f73344e616d6545524b4e535f374163636f756e7445000c355f5a4e3863757272656e637932336170706c795f63757272656e63795f7472616e7366657245524b4e535f385472616e7366657245000d04696e6974000e056170706c79000f0a9d0d060600200010080b0600200010070b3400024020012903084200510d0020004280808080a8d7bee3082001411010091a0f0b20004280808080a8d7bee308200110061a0b8a0604017e027f047e017f4100410028020441206b2208360204200029030821052000290300210720002903102104411010042004100241c000100442808080c887d7c8b21d100341d00010042007100341e000100420051003200029030021052000290308100820051008200029030010072000290300210142002105423b210441f00021034200210603400240024002400240024020054206560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b420021052008420037031820082006370310200142808080c887d7c8b21d4280808080a8d7bee308200841106a411010011a200041086a2903002101423b210441f00021034200210603400240024002400240024020054206560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b2008200637030020084200370308200142808080c887d7c8b21d4280808080a8d7bee3082008411010011a200841186a2203290300200041106a22022903005a418001100020032003290300200229030022057d370300200520082903087c20055a41b00110002008200829030820022903007c370308200029030021050240024020032903004200510d0020054280808080a8d7bee308200841106a411010091a0c010b20054280808080a8d7bee308200841106a10061a0b200041086a290300210502400240200841086a2903004200510d0020054280808080a8d7bee3082008411010091a0c010b20054280808080a8d7bee308200810061a0b4100200841206a3602040b980303027f057e017f4100410028020441106b220736020442002103423b210241e00121014200210403400240024002400240024020034207560d0020012c00002200419f7f6a41ff017141194b0d01200041a0016a21000c020b420021052003420b580d020c030b200041ea016a41002000414f6a41ff01714105491b21000b2000ad42388642388721050b2005421f83200242ffffffff0f838621050b200141016a2101200342017c2103200520048421042002427b7c2202427a520d000b42002103423b210241f00021014200210603400240024002400240024020034206560d0020012c00002200419f7f6a41ff017141194b0d01200041a0016a21000c020b420021052003420b580d020c030b200041ea016a41002000414f6a41ff01714105491b21000b2000ad42388642388721050b2005421f83200242ffffffff0f838621050b200141016a2101200342017c2103200520068421062002427b7c2202427a520d000b2007428094ebdc033703082007200637030020044280808080a8d7bee3082007411010091a4100200741106a3602040bb10303027f047e017f4100410028020441206b220836020442002105423b210441e00121034200210603400240024002400240024020054207560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b024020062000520d0042002105423b210441f00121034200210603400240024002400240024020054207560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b20062001520d00200842003703102008420037030820084200370318200841086a4118100541174b4180021000200841086a100d0b4100200841206a3602040b0bff010b0041040b04200500000041100b2254686973206170706561727320746f2062652061207472616e73666572206f6620000041c0000b0220000041d0000b072066726f6d20000041e0000b0520746f20000041f0000b086163636f756e7400004180010b2c696e746567657220756e646572666c6f77207375627472616374696e6720746f6b656e2062616c616e6365000041b0010b26696e7465676572206f766572666c6f7720616464696e6720746f6b656e2062616c616e6365000041e0010b0963757272656e6379000041f0010b097472616e7366657200004180020b1e6d6573736167652073686f72746572207468616e2065787065637465640000fd02046e616d651006617373657274020000086c6f61645f693634050000000000067072696e74690100067072696e746e0100067072696e747301000b726561644d6573736167650200000a72656d6f76655f693634030000000b726571756972654175746801000d726571756972654e6f7469636501000973746f72655f6936340400000000205f5a4e33656f733133726571756972654e6f74696365454e535f344e616d65450101301e5f5a4e33656f7331317265717569726541757468454e535f344e616d6545010130345f5a4e3863757272656e6379313273746f72654163636f756e74454e33656f73344e616d6545524b4e535f374163636f756e74450201300131355f5a4e3863757272656e637932336170706c795f63757272656e63795f7472616e7366657245524b4e535f385472616e73666572450901300131013201330134013501360137013804696e69740801300131013201330134013501360137056170706c7909013001310132013301340135013601370138010b4163636f756e744e616d65044e616d6502087472616e7366657200030466726f6d0b4163636f756e744e616d6502746f0b4163636f756e744e616d65087175616e746974790655496e743634076163636f756e740002036b65790655496e7436340762616c616e63650655496e74363401000000b298e982a4087472616e736665720100000080bafac608076163636f756e74&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="pushmessage"></a>
Pushing Message to Contract</h1>
<p>After the contract is published it initially allocates all of the currency to the <code>currency</code> account. So lets transfer some of it to our tester.</p>
<p>We can query the blockchain for the .abi of the contract, on which we can check the list of available actions and their respective message structure </p><div class="fragment"><div class="line">$ ./eosc <span class="keyword">get</span> code --a <a class="code" href="namespacecurrency.html">currency</a>.abi <a class="code" href="namespacecurrency.html">currency</a></div><div class="line">code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975</div><div class="line">saving abi to <a class="code" href="namespacecurrency.html">currency</a>.abi</div><div class="line">$ cat <a class="code" href="namespacecurrency.html">currency</a>.abi</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;types&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;newTypeName&quot;</span>: <span class="stringliteral">&quot;AccountName&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;Name&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;structs&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;base&quot;</span>: <span class="stringliteral">&quot;&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;fields&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;AccountName&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;AccountName&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;amount&quot;</span>: <span class="stringliteral">&quot;UInt64&quot;</span></div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;account&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;base&quot;</span>: <span class="stringliteral">&quot;&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;fields&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;Name&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;balance&quot;</span>: <span class="stringliteral">&quot;UInt64&quot;</span></div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;actions&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;action&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;tables&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;table&quot;</span>: <span class="stringliteral">&quot;account&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;indextype&quot;</span>: <span class="stringliteral">&quot;i64&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;keynames&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;keytype&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;account&quot;</span></div><div class="line"> }</div><div class="line"> ]</div><div class="line">}</div></div><!-- fragment --><p>From the above abi, we can see that <code>currency</code> contract accepts an action called <code>transfer</code> that accepts message with fields <code>from</code>, <code>to</code>, and <code>amount</code>.</p>
<div class="fragment"><div class="line">$ ./eosc push message <a class="code" href="namespacecurrency.html">currency</a> transfer <span class="stringliteral">&#39;{&quot;from&quot;:&quot;currency&quot;,&quot;to&quot;:&quot;tester&quot;,&quot;amount&quot;:50}&#39;</span> -S <a class="code" href="namespacecurrency.html">currency</a> -S tester -p <a class="code" href="namespacecurrency.html">currency</a>@active</div><div class="line">1589302ms thread-0 main.cpp:271 operator() ] Converting argument to binary...</div><div class="line">1589304ms thread-0 main.cpp:290 operator() ] Transaction result:</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;1c4911c0b277566dce4217edbbca0f688f7bdef761ed445ff31b31f286720057&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 1173,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 2184027244,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-08-24T18:28:07&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;quantity&quot;</span>: 50</div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;00000079b822651d00000000c84267a13200000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>Now we can transfer it from <code>tester</code> to <code>inita</code> and require the permission of <code>tester</code>. This should drain the balance of <code>tester</code> to 0.</p>
<div class="fragment"><div class="line">$ ./eosc push message <a class="code" href="namespacecurrency.html">currency</a> transfer <span class="stringliteral">&#39;{&quot;from&quot;:&quot;tester&quot;,&quot;to&quot;:&quot;inita&quot;,&quot;amount&quot;:50}&#39;</span> -S inita -S tester -p tester@active</div><div class="line">3116153ms thread-0 main.cpp:271 operator() ] Converting argument to binary...</div><div class="line">3116154ms thread-0 main.cpp:290 operator() ] Transaction result:</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;transaction_id&quot;</span>: <span class="stringliteral">&quot;56b9f0f3b9f43254af446c5dca02a6fcb24ebcdb506d7248947fd4d52a27972a&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;processed&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;refBlockNum&quot;</span>: 2882,</div><div class="line"> <span class="stringliteral">&quot;refBlockPrefix&quot;</span>: 1880685856,</div><div class="line"> <span class="stringliteral">&quot;expiration&quot;</span>: <span class="stringliteral">&quot;2017-08-24T19:53:34&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;scope&quot;</span>: [</div><div class="line"> <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;tester&quot;</span></div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;signatures&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;messages&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;code&quot;</span>: <span class="stringliteral">&quot;currency&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;type&quot;</span>: <span class="stringliteral">&quot;transfer&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;authorization&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;permission&quot;</span>: <span class="stringliteral">&quot;active&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;data&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;from&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;to&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;quantity&quot;</span>: 50</div><div class="line"> },</div><div class="line"> <span class="stringliteral">&quot;hex_data&quot;</span>: <span class="stringliteral">&quot;00000000c84267a1000000008040934b3200000000000000&quot;</span></div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;inita&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> },{</div><div class="line"> <span class="stringliteral">&quot;name&quot;</span>: <span class="stringliteral">&quot;tester&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;output&quot;</span>: {</div><div class="line"> <span class="stringliteral">&quot;notify&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;sync_transactions&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;async_transactions&quot;</span>: []</div><div class="line"> }</div><div class="line"> ]</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>Now that <code>tester</code> has a balance of 0, if we attempt this transfer a second time it should fail:</p>
<div class="fragment"><div class="line">$ ./eosc push message <a class="code" href="namespacecurrency.html">currency</a> transfer <span class="stringliteral">&#39;{&quot;from&quot;:&quot;tester&quot;,&quot;to&quot;:&quot;inita&quot;,&quot;amount&quot;:50}&#39;</span> -S inita -S tester -p tester@active</div><div class="line">3543610ms thread-0 main.cpp:271 operator() ] Converting argument to binary...</div><div class="line">3543615ms thread-0 main.cpp:311 main ] Failed with error: 10 assert_exception: Assert Exception</div><div class="line">status_code == 200: Error</div><div class="line">: 10 assert_exception: Assert Exception</div><div class="line">test: assertion failed: integer underflow subtracting token balance</div><div class="line"> {<span class="stringliteral">&quot;s&quot;</span>:<span class="stringliteral">&quot;integer underflow subtracting token balance&quot;</span>,<span class="stringliteral">&quot;ptr&quot;</span>:176}</div><div class="line"> thread-1 wasm_interface.cpp:248 assertnonei32i32</div><div class="line"></div><div class="line">[...snipped...]</div></div><!-- fragment --><h1><a class="anchor" id="querycontract"></a>
Querying Contract</h1>
<p>After doing the transfer action on <code>currency</code> contract, we can verify the amount of token held by each account by looking at <code>currency</code>'s <code>account</code> table.</p>
<p>This table is stored on the scope of each account instead of on <code>currency</code> scope.</p>
<div class="fragment"><div class="line">$./eosc <span class="keyword">get</span> table tester <a class="code" href="namespacecurrency.html">currency</a> account</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;rows&quot;</span>: [],</div><div class="line"> <span class="stringliteral">&quot;more&quot;</span>: <span class="keyword">false</span></div><div class="line">}</div><div class="line">$./eosc <span class="keyword">get</span> table inita <a class="code" href="namespacecurrency.html">currency</a> account</div><div class="line">{</div><div class="line"> <span class="stringliteral">&quot;rows&quot;</span>: [{</div><div class="line"> <span class="stringliteral">&quot;account&quot;</span>: <span class="stringliteral">&quot;account&quot;</span>,</div><div class="line"> <span class="stringliteral">&quot;balance&quot;</span>: 50</div><div class="line"> }</div><div class="line"> ],</div><div class="line"> <span class="stringliteral">&quot;more&quot;</span>: <span class="keyword">true</span></div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="particularnode"></a>
Connecting to Particular Node</h1>
<p>By default, <code>eosc</code> will connect to <code>eosd</code> running on localhost port 8888. You can connect to another <code>eosd</code> node by specifying its host and port. </p><div class="fragment"><div class="line">./eosc -H localhost -p 8889</div></div><!-- fragment --><h1><a class="anchor" id="separatewallet"></a>
Using Separate Wallet App</h1>
<p>Instead of using the wallet functionality built-in to <code>eosd</code>, you can also use a separate wallet app which can be found inside programs/eos-walletd. By default, port 8888 is used by <code>eosd</code>, so choose another port for the wallet app. </p><div class="fragment"><div class="line">./<a class="code" href="namespaceeos.html">eos</a>-walletd --http-server-endpoint 127.0.0.1:8887</div></div><!-- fragment --><p> Then for any operation that requires signing, use the &ndash;wallet-host and &ndash;wallet-port option </p><div class="fragment"><div class="line">./eosc --wallet-host 127.0.0.1 --wallet-port 8887 &lt;COMMAND&gt; &lt;SUBCOMMAND&gt; &lt;PARAMS&gt;</div></div><!-- fragment --><h1><a class="anchor" id="skippingsignature"></a>
Skipping Signatures</h1>
<p>As an easy way for developers to test functionality without dealing with keys, <code>eosd</code> can be run so that Transaction signatures are not required. </p><div class="fragment"><div class="line">./eosd --skip-transaction-signatures</div></div><!-- fragment --><p> And then for any operation that requires signing, use the <code>-s</code> option </p><div class="fragment"><div class="line">./eosc &lt;COMMAND&gt; &lt;SUBCOMMAND&gt; -s &lt;PARAMS&gt;</div></div><!-- fragment --><h1><a class="anchor" id="additionaldoc"></a>
Additional Documentation</h1>
<p>eosc contains documentation for all of its commands. For a list of all commands known to eosc, simply run it with no arguments: </p><div class="fragment"><div class="line">$ ./eosc</div><div class="line">ERROR: RequiredError: Subcommand required</div><div class="line">Command Line Interface to Eos Daemon</div><div class="line">Usage: ./eosc [OPTIONS] SUBCOMMAND</div><div class="line"></div><div class="line">Options:</div><div class="line"> -h,--help Print <span class="keyword">this</span> help message and exit</div><div class="line"> -H,--host TEXT=localhost the host where eosd is running</div><div class="line"> -p,--port UINT=8888 the port where eosd is running</div><div class="line"> --wallet-host TEXT=localhost</div><div class="line"> the host where <a class="code" href="namespaceeos.html">eos</a>-walletd is running</div><div class="line"> --wallet-port UINT=8888 the port where <a class="code" href="namespaceeos.html">eos</a>-walletd is running</div><div class="line"></div><div class="line">Subcommands:</div><div class="line"> create Create various items, on and off the blockchain</div><div class="line"> <span class="keyword">get</span> Retrieve various items and information from the blockchain</div><div class="line"> <span class="keyword">set</span> Set or update blockchain state</div><div class="line"> transfer Transfer EOS from account to account</div><div class="line"> wallet Interact with local wallet</div><div class="line"> benchmark Configure and execute benchmarks</div><div class="line"> push Push arbitrary transactions to the blockchain</div></div><!-- fragment --><p> To get help with any particular subcommand, run it with no arguments as well: </p><div class="fragment"><div class="line">$ ./eosc create</div><div class="line">ERROR: RequiredError: Subcommand required</div><div class="line">Create various items, on and off the blockchain</div><div class="line">Usage: ./eosc create SUBCOMMAND</div><div class="line"></div><div class="line">Subcommands:</div><div class="line"> key Create a <span class="keyword">new</span> keypair and <a class="code" href="namespaceeos.html#a1df73defa04d39763089df7faa35a934">print</a> the <span class="keyword">public</span> and <span class="keyword">private</span> keys</div><div class="line"> account Create a <span class="keyword">new</span> account on the blockchain</div><div class="line">$ ./eosc create account</div><div class="line">ERROR: RequiredError: creator</div><div class="line">Create a <span class="keyword">new</span> account on the blockchain</div><div class="line">Usage: ./eosc create account creator name OwnerKey ActiveKey</div><div class="line"></div><div class="line">Positionals:</div><div class="line"> creator TEXT The name of the account creating the <span class="keyword">new</span> account</div><div class="line"> name TEXT The name of the <span class="keyword">new</span> account</div><div class="line"> OwnerKey TEXT The owner <span class="keyword">public</span> key <span class="keywordflow">for</span> the account</div><div class="line"> ActiveKey TEXT The active <span class="keyword">public</span> key <span class="keywordflow">for</span> the account</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
......
......@@ -14,7 +14,6 @@ set(sources
string_escape.cpp
tempdir.cpp
words.cpp
wasm.cpp
${HEADERS})
#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY)
......
#pragma once
#include <string>
#include <vector>
namespace eos { namespace utilities {
std::vector<uint8_t> assemble_wast(const std::string& wast);
} } // namespace eos::utilities
#include <eos/utilities/wasm.hpp>
#include <fc/exception/exception.hpp>
#include <Inline/BasicTypes.h>
#include <IR/Module.h>
#include <IR/Validate.h>
#include <WAST/WAST.h>
#include <WASM/WASM.h>
#include <iostream>
#include <iomanip>
namespace eos { namespace utilities {
std::vector<uint8_t> assemble_wast( const std::string& wast ) {
IR::Module module;
std::vector<WAST::Error> parseErrors;
WAST::parseModule(wast.c_str(),wast.size(),module,parseErrors);
if(parseErrors.size())
{
// Print any parse errors;
std::cerr << "Error parsing WebAssembly text file:" << std::endl;
for(auto& error : parseErrors)
{
std::cerr << ":" << error.locus.describe() << ": " << error.message.c_str() << std::endl;
std::cerr << error.locus.sourceLine << std::endl;
std::cerr << std::setw(error.locus.column(8)) << "^" << std::endl;
}
FC_ASSERT( !"error parsing wast" );
}
try
{
// Serialize the WebAssembly module.
Serialization::ArrayOutputStream stream;
WASM::serialize(stream,module);
return stream.getBytes();
}
catch(Serialization::FatalSerializationException exception)
{
std::cerr << "Error serializing WebAssembly binary file:" << std::endl;
std::cerr << exception.message << std::endl;
throw;
}
}
} } // namespace eos::utilities
......@@ -96,7 +96,9 @@ void producer_plugin::set_program_options(
auto private_key_default = std::make_pair(chain::public_key_type(default_priv_key.get_public_key()),
eos::utilities::key_to_wif(default_priv_key));
command_line_options.add_options()
boost::program_options::options_description producer_options;
producer_options.add_options()
("enable-stale-production", boost::program_options::bool_switch()->notifier([this](bool e){my->_production_enabled = e;}), "Enable block production, even if the chain is stale.")
("required-participation", boost::program_options::bool_switch()->notifier([this](int e){my->_required_producer_participation = uint32_t(e*config::Percent1);}), "Percent of producers (0-99) that must be participating in order to produce blocks")
("producer-name,p", boost::program_options::value<vector<string>>()->composing()->multitoken(),
......@@ -105,7 +107,8 @@ void producer_plugin::set_program_options(
fc::json::to_string(private_key_default)),
"Tuple of [PublicKey, WIF private key] (may specify multiple times)")
;
config_file_options.add(command_line_options);
command_line_options.add(producer_options);
config_file_options.add(producer_options);
}
template<typename T>
......
......@@ -379,7 +379,9 @@ launcher_def::write_config_file (eosd_def &node) {
<< "\",\"" << kp.wif_private_key << "\"]\n";
}
cfg << "plugin = eos::producer_plugin\n"
<< "plugin = eos::chain_api_plugin\n";
<< "plugin = eos::chain_api_plugin\n"
<< "plugin = eos::account_history_plugin\n"
<< "plugin = eos::account_history_api_plugin\n";
for (auto &p : node.producers) {
cfg << "producer-name = " << p << "\n";
}
......
digraph G
{
initg->initb [dir="both"]
initg->initc [dir="both"]
initg->initd [dir="both"]
initg->inite [dir="both"]
initg->initf [dir="both"]
initg->inita [dir="both"]
inita->initb [dir="both"]
inita->initd [dir="both"]
inita->initf [dir="both"]
inita->inith [dir="both"]
inita->initj [dir="both"]
initb->initc [dir="both"]
initb->inite [dir="both"]
initb->initg [dir="both"]
initb->initi [dir="both"]
initb->initk [dir="both"]
initc->initd [dir="both"]
initc->initf [dir="both"]
initc->inith [dir="both"]
initc->initj [dir="both"]
initd->inite [dir="both"]
initd->initg [dir="both"]
initd->initi [dir="both"]
initd->initk [dir="both"]
inite->initf [dir="both"]
inite->inith [dir="both"]
inite->initj [dir="both"]
initf->initg [dir="both"]
initf->initi [dir="both"]
initf->initk [dir="both"]
initg->inith [dir="both"]
initg->initi [dir="both"]
initg->initj [dir="both"]
initg->initk [dir="both"]
inith->initi [dir="both"]
inith->initk [dir="both"]
initi->initj [dir="both"]
initi->initk [dir="both"]
initj->initk [dir="both"]
}
star.png

45.7 KB | W: | H:

star.png

117.9 KB | W: | H:

star.png
star.png
star.png
star.png
  • 2-up
  • Swipe
  • Onion skin
[toc]
# EOS Testnet
#EOS Testnet
To date, all work done to experiment with the EOS blockchain has been performed using a single instance of eosd hosting all 21 block producers. While this is a perfectly valid solution for validating features of the blockchain, developing new contracts, or whatever, it does not scale. Nor does it expose the sort of issues raised when contract and block data must be shared across multiple instances. Providing the ability to scale involves deploying multiple eosd nodes across many hosts and lining then into a peer-to-peer (p2p) network. Composing this network involves tailoring and distributing configuration files, coordinating starts and stops and other tasks.
Doing this manually is a tedious task and easily error prone. Fortunately a solution is provided, in the form of the Launcher application, described below.
......@@ -33,26 +33,26 @@ Network topology or "shape" describes how the nodes are connected in order to sh
The Launcher has definitions of three different network "shapes" based on inter-nodal connections, which can be selected by a command line option, or you can supply your own network topology by editing the Launcher generated configuration file.
#### Ring network
####Ring network
![](ring.png "Ring Diagram")
This is the simplest network, where each node identifies just the node next to it as it's only peer.
#### Star network
####Star network
![](star.png "Star Diagram")
A "star" is intended to support the use larger number nodes in the testnet. In this case the number of peers connected to a node and the distribution of those nodes varies based on the number of nodes in the network.
A "star" is intended to support a larger number of nodes in the testnet. In this case the number of peers connected to a node and the distribution of those nodes varies based on the number of nodes in the network.
#### Mesh network
####Mesh network
![](mesh.png "Mesh Diagram")
In a "mesh" network, each node is connected to as many peer nodes as possible.
# The Launcher Application
#The Launcher Application
To address the complexity implied by distributing multiple eosd nodes across a LAN or a wider network, the launcher application was created.
Based on a handful of command line arguments the Launcher is able to compose per-node configuration files, distribute these files securely amongst the peer hosts, then start up the multiple instances of eosd.
Eosd instances started this way have their output logged in individual text files. Finally the launcher application is also able to shut down some or all of the test network.
## Running the Launcher application
##Running the Launcher application
The launcher program is used to configure and deploy producing and non-producing eosd nodes that talk to each other using configured routes. The configuration for each node is stored in separate directories, permitting multiple nodes to be active on the same host, assuming the machine has sufficient memory and disk space for multiple eosd instances. The launcher makes use of multiple configuration sources in order to deploy a testnet. A handful of command line arguments can be used to set up simple local networks.
......@@ -145,7 +145,7 @@ The ssh helper fields are paths to ssh and scp, an identity if necessary, and an
The rest of the testnet.json file is the collection of node descriptors. The fragment shown above was created with the command line `programs/launcher/launcher -p6 -s mesh -o testnet.json` and then edited to refer to a remote host named "remoteserv."
### Elements Of The JSON File
###Elements Of The JSON File
This table describes all of the key/value pairs used in the testnet.json file.
|Value | Description
......@@ -177,7 +177,7 @@ keys | specify the authentication tokens for this node.
peers | this list indicates the other nodes in the network to which this one actively connects. Since this file may be edited to alter the hostname, public name, or p2p port values, the peers list here holds aliases for the actual endpoints eventually written to the individual config.ini files.
producers | this list identifies which of the producers from the genesis.json file are held by this node. Note that the launcher uses a round-robin algorithm to spread the producer instances across the producing nodes.
### Provisioning Distributed Servers
###Provisioning Distributed Servers
The ssh_helper section of the testnet.json file contains the ssh elements necessary to connect and issue commands to other servers. In addition to the ssh_helper section which provides access to global configuration settings, the per-node configuration may provide overriding identity and connection arguments.
It is also necessary to provision the server by at least copying the eosd executable, and the genesis.json files to their appropriate locations relative to some named EOS root directory. For example, I defined the EOS root to be `/home/phil/blockchain/eos`. When run, the launcher will run through a variety of shell commands using ssh and finally using scp to copy a config.ini file to the appropriate data directory on the remote.
......@@ -196,7 +196,7 @@ The launcher app creates a separate date and configuration directory for each no
A file called "last_run.json" contains hints for a later instance of the launcher to be able to kill local and remote nodes when run with -k.
# What Remains To Be Done
#What Remains To Be Done
Functionality that remains to be implemented: caching signed transactions then purging them on a schedule. Sending summaries of blocks rather than whole blocks. Optimizing the routing between nodes. Failover during new node synchronization if a peer fails to respond timely enough
......
......@@ -76,7 +76,7 @@ inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
#define SETCODE3(chain, acct, wast) \
{ \
auto wasm = eos::utilities::assemble_wast(wast); \
auto wasm = eos::chain::wast_to_wasm(wast); \
types::setcode handler; \
handler.account = #acct; \
handler.code.assign(wasm.begin(), wasm.end()); \
......
#pragma once
#include <eos/utilities/wasm.hpp>
#include <eos/chain/wast_to_wasm.hpp>
#include "macro_support.hpp"
......
......@@ -3,7 +3,7 @@
error()
{
(>&2 echo $1)
cleanup
killAll
exit 1
}
......@@ -15,26 +15,59 @@ verifyErrorCode()
fi
}
cleanup()
killAll()
{
programs/launcher/launcher -k 9
kill -9 $WALLETD_PROC_ID
}
cleanup()
{
rm -rf tn_data_0
rm -rf tn_wallet_0
rm -rf test_wallet_0
}
# result stored in HEAD_BLOCK_NUM
getHeadBlockNum()
{
INFO="$(programs/eosc/eosc get info)"
verifyErrorCode "eosc get info"
HEAD_BLOCK_NUM="$(echo "$INFO" | awk '/head_block_num/ {print $2}')"
# remove trailing coma
HEAD_BLOCK_NUM=${HEAD_BLOCK_NUM%,}
}
waitForNextBlock()
{
getHeadBlockNum
NEXT_BLOCK_NUM=$((HEAD_BLOCK_NUM+1))
while [ "$HEAD_BLOCK_NUM" -lt "$NEXT_BLOCK_NUM" ]; do
sleep 0.25
getHeadBlockNum
done
}
# cleanup from last run
cleanup
INITA_PRV_KEY="5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
INITB_PRV_KEY="5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
LOG_FILE=eosd_run_test.log
# eosd
programs/launcher/launcher -p 1
programs/launcher/launcher
verifyErrorCode "launcher"
sleep 9
sleep 7
count=`grep -c "generated block" tn_data_0/stderr.txt`
if [ $count == 0 ]; then
if [[ $count == 0 ]]; then
error "FAILURE - no blocks produced"
fi
# create 2 keys
# save starting block number
getHeadBlockNum
START_BLOCK_NUM=$HEAD_BLOCK_NUM
# create 3 keys
KEYS="$(programs/eosc/eosc create key)"
verifyErrorCode "eosc create key"
PRV_KEY1="$(echo "$KEYS" | awk '/Private/ {print $3}')"
......@@ -43,12 +76,16 @@ KEYS="$(programs/eosc/eosc create key)"
verifyErrorCode "eosc create key"
PRV_KEY2="$(echo "$KEYS" | awk '/Private/ {print $3}')"
PUB_KEY2="$(echo "$KEYS" | awk '/Public/ {print $3}')"
if [ -z "$PRV_KEY1" ] || [ -z "$PRV_KEY2" ] || [ -z "$PUB_KEY1" ] || [ -z "$PUB_KEY2" ]; then
KEYS="$(programs/eosc/eosc create key)"
verifyErrorCode "eosc create key"
PRV_KEY3="$(echo "$KEYS" | awk '/Private/ {print $3}')"
PUB_KEY3="$(echo "$KEYS" | awk '/Public/ {print $3}')"
if [ -z "$PRV_KEY1" ] || [ -z "$PRV_KEY2" ] || [ -z "$PRV_KEY3" ] || [ -z "$PUB_KEY1" ] || [ -z "$PUB_KEY2" ] || [ -z "$PUB_KEY3" ]; then
error "FAILURE - create keys"
fi
# walletd
programs/eos-walletd/eos-walletd --data-dir tn_wallet_0 --http-server-endpoint=127.0.0.1:8899 > test_walletd_output.log 2>&1 &
programs/eos-walletd/eos-walletd --data-dir test_wallet_0 --http-server-endpoint=127.0.0.1:8899 > test_walletd_output.log 2>&1 &
verifyErrorCode "eos-walletd"
WALLETD_PROC_ID=$!
sleep 3
......@@ -56,43 +93,208 @@ sleep 3
# import into a wallet
PASSWORD="$(programs/eosc/eosc --wallet-port 8899 wallet create --name test)"
verifyErrorCode "eosc wallet create"
# strip out password from output
PASSWORD="$(echo "$PASSWORD" | awk '/PW/ {print $1}')"
# remove leading/trailing quotes
PASSWORD=${PASSWORD#\"}
PASSWORD=${PASSWORD%\"}
programs/eosc/eosc --wallet-port 8899 wallet import --name test $PRV_KEY1
verifyErrorCode "eosc wallet import"
programs/eosc/eosc --wallet-port 8899 wallet import --name test $PRV_KEY2
verifyErrorCode "eosc wallet import"
programs/eosc/eosc --wallet-port 8899 wallet import --name test $INITA_PRV_KEY
programs/eosc/eosc --wallet-port 8899 wallet import --name test $PRV_KEY3
verifyErrorCode "eosc wallet import"
# create wallet for inita
PASSWORD_INITA="$(programs/eosc/eosc --wallet-port 8899 wallet create --name inita)"
verifyErrorCode "eosc wallet create"
# strip out password from output
PASSWORD_INITA="$(echo "$PASSWORD_INITA" | awk '/PW/ {print $1}')"
# remove leading/trailing quotes
PASSWORD_INITA=${PASSWORD_INITA#\"}
PASSWORD_INITA=${PASSWORD_INITA%\"}
programs/eosc/eosc --wallet-port 8899 wallet import --name inita $INITA_PRV_KEY
verifyErrorCode "eosc wallet import"
# lock wallet
programs/eosc/eosc --wallet-port 8899 wallet lock --name test
verifyErrorCode "eosc wallet lock"
# unlock wallet
echo $PASSWORD | programs/eosc/eosc --wallet-port 8899 wallet unlock --name test
verifyErrorCode "eosc wallet unlock"
# lock via lock_all
programs/eosc/eosc --wallet-port 8899 wallet lock_all
verifyErrorCode "eosc wallet lock_all"
# unlock wallet again
echo $PASSWORD | programs/eosc/eosc --wallet-port 8899 wallet unlock --name test
verifyErrorCode "eosc wallet unlock"
# wallet list
OUTPUT=$(programs/eosc/eosc --wallet-port 8899 wallet list)
verifyErrorCode "eosc wallet list"
count=`echo $OUTPUT | grep "test" | grep -c "\*"`
if [[ $count == 0 ]]; then
error "FAILURE - wallet list did not include \*"
fi
# wallet keys
OUTPUT=$(programs/eosc/eosc --wallet-port 8899 wallet keys)
verifyErrorCode "eosc wallet keys"
count=`echo $OUTPUT | grep -c "$PRV_KEY1"`
if [[ $count == 0 ]]; then
error "FAILURE - wallet keys did not include $PRV_KEY1"
fi
count=`echo $OUTPUT | grep -c "$PRV_KEY2"`
if [[ $count == 0 ]]; then
error "FAILURE - wallet keys did not include $PRV_KEY2"
fi
# lock via lock_all
programs/eosc/eosc --wallet-port 8899 wallet lock_all
verifyErrorCode "eosc wallet lock_all"
# unlock wallet inita
echo $PASSWORD_INITA | programs/eosc/eosc --wallet-port 8899 wallet unlock --name inita
verifyErrorCode "eosc wallet unlock inita"
OUTPUT=$(programs/eosc/eosc --wallet-port 8899 wallet keys)
count=`echo $OUTPUT | grep -c "$INITA_PRV_KEY"`
if [[ $count == 0 ]]; then
error "FAILURE - wallet keys did not include $INITA_PRV_KEY"
fi
# create new account
programs/eosc/eosc --wallet-port 8899 create account inita tester $PUB_KEY1 $PUB_KEY2
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 create account inita testera $PUB_KEY1 $PUB_KEY3)"
verifyErrorCode "eosc create account"
waitForNextBlock
# verify account created
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account tester)"
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account testera)"
verifyErrorCode "eosc get account"
count=`echo $ACCOUNT_INFO | grep -c "exception"`
if [ $count != 0 ]; then
error "FAILURE - account creation caused exception: $ACCOUNT_INFO"
fi
count=`echo $ACCOUNT_INFO | grep -c "staked_balance"`
if [ $count == 0 ]; then
error "FAILURE - account creation failed: $ACCOUNT_INFO"
fi
# transfer
programs/eosc/eosc --wallet-port 8899 transfer inita tester 975321 "test transfer"
TRANSFER_INFO="$(programs/eosc/eosc --wallet-port 8899 transfer inita testera 975321 "test transfer")"
verifyErrorCode "eosc transfer"
# verify transfer
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account tester)"
count=`echo $ACCOUNT_INFO | grep -c "exception"`
if [ $count != 0 ]; then
error "FAILURE - transfer caused exception: $ACCOUNT_INFO"
fi
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account testera)"
count=`echo $ACCOUNT_INFO | grep -c "97.5321"`
if [ $count == 0 ]; then
error "FAILURE - transfer failed: $ACCOUNT_INFO"
fi
# create another new account via initb
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 create account initb testerb $PUB_KEY2 $PUB_KEY3)"
verifyErrorCode "eosc create account"
waitForNextBlock
#
# now transfer from testera to testerb using keys from testera
#
# lock via lock_all
programs/eosc/eosc --wallet-port 8899 wallet lock_all
verifyErrorCode "eosc wallet lock_all"
# unlock wallet
echo $PASSWORD | programs/eosc/eosc --wallet-port 8899 wallet unlock --name test
verifyErrorCode "eosc wallet unlock"
# transfer
TRANSFER_INFO="$(programs/eosc/eosc --wallet-port 8899 transfer testera testerb 975311 "test transfer a->b")"
verifyErrorCode "eosc transfer"
TRANS_ID="$(echo "$TRANSFER_INFO" | awk '/transaction_id/ {print $2}')"
waitForNextBlock
# remove leading/trailing quotes
TRANS_ID=${TRANS_ID#\"}
TRANS_ID=${TRANS_ID%\",}
# verify transfer
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account testerb)"
verifyErrorCode "eosc get account testerb"
count=`echo $ACCOUNT_INFO | grep -c "97.5311"`
if [ $count == 0 ]; then
error "FAILURE - transfer failed: $ACCOUNT_INFO"
fi
# get accounts via public key
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get accounts $PUB_KEY3)"
verifyErrorCode "eosc get accounts pub_key3"
count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [ $count == 0 ]; then
error "FAILURE - get accounts failed: $ACCOUNT_INFO"
fi
count=`echo $ACCOUNT_INFO | grep -c "testerb"`
if [ $count == 0 ]; then
error "FAILURE - get accounts failed: $ACCOUNT_INFO"
fi
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get accounts $PUB_KEY1)"
verifyErrorCode "eosc get accounts pub_key1"
count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [ $count == 0 ]; then
error "FAILURE - get accounts failed: $ACCOUNT_INFO"
fi
count=`echo $ACCOUNT_INFO | grep -c "testerb"`
if [ $count != 0 ]; then
error "FAILURE - get accounts failed: $ACCOUNT_INFO"
fi
# get servant accounts
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get servants inita)"
verifyErrorCode "eosc get servants inita"
count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [ $count == 0 ]; then
error "FAILURE - get servants failed: $ACCOUNT_INFO"
fi
count=`echo $ACCOUNT_INFO | grep -c "testerb"`
if [ $count != 0 ]; then
error "FAILURE - get servants failed: $ACCOUNT_INFO"
fi
ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get servants testera)"
verifyErrorCode "eosc get servants testera"
count=`echo $ACCOUNT_INFO | grep -c "testera"`
if [ $count != 0 ]; then
error "FAILURE - get servants failed: $ACCOUNT_INFO"
fi
# get transaction
TRANS_INFO="$(programs/eosc/eosc --wallet-port 8899 get transaction $TRANS_ID)"
verifyErrorCode "eosc get transaction trans_id"
count=`echo $TRANS_INFO | grep -c "transfer"`
if [ $count == 0 ]; then
error "FAILURE - get transaction trans_id failed: $TRANS_INFO"
fi
count=`echo $TRANS_INFO | grep -c "975311"`
if [ $count == 0 ]; then
error "FAILURE - get transaction trans_id failed: $TRANS_INFO"
fi
# get transactions
TRANS_INFO="$(programs/eosc/eosc --wallet-port 8899 get transactions testera)"
verifyErrorCode "eosc get transactions testera"
count=`echo $TRANS_INFO | grep -c "$TRANS_ID"`
if [ $count == 0 ]; then
error "FAILURE - get transactions testera failed: $TRANS_INFO"
fi
# should be able to get every block from beginning to end
getHeadBlockNum
CURRENT_BLOCK_NUM=$HEAD_BLOCK_NUM
NEXT_BLOCK_NUM=1
while [ "$NEXT_BLOCK_NUM" -le "$HEAD_BLOCK_NUM" ]; do
INFO="$(programs/eosc/eosc get block $NEXT_BLOCK_NUM)"
verifyErrorCode "eosc get block"
NEXT_BLOCK_NUM=$((NEXT_BLOCK_NUM+1))
done
killAll
cleanup
echo SUCCESS!
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册