Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'eos-noon' into DAWN-507-verify-balance-GH-#1139
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner authored Jan 23, 2018
2 parents 433f0ae + 26eecaa commit a3760d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ If all went well, you will receive output similar to the following:

```json
{
"name": "currency",
"eos_balance": 0,
"staked_balance": 1,
"unstaking_balance": 0,
"last_unstaking_time": "2106-02-07T06:28:15"
}
"account_name": "currency",
"eos_balance": "0.0000 EOS",
"staked_balance": "1.0000 EOS",
"unstaking_balance": "0.0000 EOS",
"last_unstaking_time": "2035-10-29T06:32:22",
...
```

Now import the active private key generated previously in the wallet:
Expand Down Expand Up @@ -313,14 +313,20 @@ It will return something like:
code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975
```

Before using the currency contract, you must issue the currency.

```bash
./eosioc push action currency issue '{"to":"currency","quantity":"1000.0000 CUR"}' --permission currency@active
```

Next verify the currency contract has the proper initial balance:

```bash
./eosioc get table currency currency account
{
"rows": [{
"account": "account",
"balance": 1000000000
"currency": 1381319428,
"balance": 10000000
}
],
"more": false
Expand All @@ -332,16 +338,16 @@ Next verify the currency contract has the proper initial balance:

Anyone can send any message to any contract at any time, but the contracts may reject messages which are not given necessary permission. Messages are not sent "from" anyone, they are sent "with permission of" one or more accounts and permission levels. The following commands show a "transfer" message being sent to the "currency" contract.

The content of the message is `'{"from":"currency","to":"inita","quantity":50}'`. In this case we are asking the currency contract to transfer funds from itself to someone else. This requires the permission of the currency contract.
The content of the message is `'{"from":"currency","to":"inita","quantity":"20.0000 CUR","memo":"any string"}'`. In this case we are asking the currency contract to transfer funds from itself to someone else. This requires the permission of the currency contract.

```bash
./eosioc push action currency transfer '{"from":"currency","to":"inita","amount":50}' --permission currency@active
./eosioc push action currency transfer '{"from":"currency","to":"inita","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
```

Below is a generalization that shows the `currency` account is only referenced once, to specify which contract to deliver the `transfer` message to.

```bash
./eosioc push action currency transfer '{"from":"${usera}","to":"${userb}","amount":50}' --permission ${usera}@active
./eosioc push action currency transfer '{"from":"${usera}","to":"${userb}","quantity":"20.0000 CUR","memo":""}' --permission ${usera}@active
```

As confirmation of a successfully submitted transaction, you will receive JSON output that includes a `transaction_id` field.
Expand All @@ -355,24 +361,24 @@ So now check the state of both of the accounts involved in the previous transact
./eosioc get table inita currency account
{
"rows": [{
"account": "account",
"balance": 50
"currency": 1381319428,
"balance": 200000
}
],
"more": false
}
./eosioc get table currency currency account
{
"rows": [{
"account": "account",
"balance": 999999950
"currency": 1381319428,
"balance": 9800000
}
],
"more": false
}
```

As expected, the receiving account **inita** now has a balance of **50** tokens, and the sending account now has **50** less tokens than its initial supply.
As expected, the receiving account **inita** now has a balance of **20** tokens, and the sending account now has **20** less tokens than its initial supply.

<a name="localtestnet"></a>
## Running multi-node local testnet
Expand Down
2 changes: 1 addition & 1 deletion programs/eosioc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ int main( int argc, char** argv ) {
string ownerKey;
string activeKey;
bool skip_sign = false;
uint64_t staked_deposit=1000;
uint64_t staked_deposit=10000;
auto createAccount = create->add_subcommand("account", localized("Create a new account on the blockchain"), false);
createAccount->add_option("creator", creator, localized("The name of the account creating the new account"))->required();
createAccount->add_option("name", account_name, localized("The name of the new account"))->required();
Expand Down

0 comments on commit a3760d8

Please sign in to comment.