1、inline action简单来说就是action调用另外一个action, 具体来说就是一个智能合约的代码调用另外一个智能合约的函数。现在的eos(好像是自从dawn 4.0之后),只要在合约中调用另一个合约的action,不管以什么代码格式调用,都自动是inline action。
eosio.code 的解释:
eoiso.code这一特殊权限是dawn4.0后新增的内部特殊权限,用来加强inline action的安全性。比如alice调用智能合约contract1.test,一开始alice看过contract1.test的逻辑,发现它只是一个打印函数,并不会调用其他合约。所以alice以自己active的权限alice@active去执行contract1.test。但是contract1的拥有者某一天可能偷偷更改了test的实现,在test函数中调用eosio.token的transfer函数以alice@active权限就可以取走alice的EOS. 为了解决权限乱用问题,EOS新增了eosio.code这个特殊权限。采用eosio.code后,contract1.test要以alice@active去调用其它合约如eosio.token,必须得到alice的授权,即必须在alice@active里添加contract1@eosio.code授权,让 contract1 在自己的合约代码里运行的代码具有 alice@active 权限。而且只有在 contract1 自己的合约代码里才能拿到alice@active权限,在外部手动以contract1的active权限调用alice的active权限的action(如转账等)是不会成功的,非得在contract1的自己合约代码里调用才会获得alice@active 权限。
https://eosio.stackexchange.com/questions/1621/require-inline-action-be-sent-by-contract-and-not-account
UPDATE: This is the code I used to experiment with all combinations of permissions I could come up with: https://github.com/andresberrios/permissions_test
After a lot of experimentation, I finally understand how permissions work in EOSIO!
EOS Permission Model - Overview
- An account can have various permissions (like owner and active), which are represented by an account@permission pair. 一个账户会有很多类型的权限级别。
- Permissions (which are like roles) can be linked to specific actions of specific contracts to allow those permissions to execute those actions (
linkauth
). By default, theowner
andactive
permissions can do anything exceptactive
can't change the owner permission. 权限级别相当于角色的意思。角色可以被指定赋予给特定合约的特定action,从而允许这些action执行这些角色能执行的actions。 - Permissions are controlled by an "authority", which is the multisig configuration of who can give that permission (in other words, who can act under that role).
- Within this multisig configuration, you can have a combination of public keys and other permissions (account@permission pairs), which makes permissions an intrinsically recursive construct.
Acting as another account
Contracts in general should use require_auth(account)
and not require_auth2(account, permission)
unless there is a very specific reason to do so. Using require_auth2
to require a specific permission of an account can hinder the configurability of the EOSIO permission system. This is because in general, if actions simply require the auth of an account, then that means they are implicitly requiring one of the following permissions of that account:
- The
owner
permission. - The
active
permission. - Any other custom permission that the user decided to create for their account in order to give granular authorization to specific contract actions.
Point 3 means that a user can create a permission (as I mentioned, it can be seen as a "role") called for example ramtrader
and then use linkauth
to authorize that permission to use the eosio::buyram
and eosio::sellram
system contract actions. This can work with any contract, not only the system contract. This way, when defining the ramtrader
permission, users will need to specify an authority for it (a multisig configuration), and this authority could specify that the only object that can act under this permission is accountb@active
, for example, giving access to the accountb
account to buy and sell RAM for account
.
Contract code acting as another account(合约中运行的代码调用/使用其它合约的权限)
Now that we understand how to act as another account, we can figure out how to allow a contract's code to act as another account, be it for transferring funds (eosio.token::transfer
action) or just calling another contract's actions.
When contracts call inline actions, they are supposed to send the right permissions for that action. If for instance a contract that lives in the contract
account would try to buy RAM for account
using the funds of account
itself, it would need to provide the same permissions that account
is required to provide when they buy RAM for themselves manually. If we use the account@active
permission, then the contract would need to send that permission in the inline action, and not contract@eosio.code
as many of us could end up thinking (the documentation on this is very scarce and confusing). In order for the code in the contract
account to be able to provide that permission, first account
would have to add authorization for the code of contract
to the authority (multisig config) that rules it's account@active
permission. 当合约调用inline actions,他们必须具有调用这些action所需要的权限。
This can be achieved by adding the contract@eosio.code
permission to the authority, which is a special permission defined by the EOSIO software to specify that only the contract code of the contract
account will be able to act under the permission (role) ruled by that authority. This means that the account@active
authority would contain the public key that the owner of that account controls, as well as the contract@eosio.code
permission. 这表明account@active
的权限被授权给自己的公钥及contract@eosio.code
。
This effectively implements what you were looking for: Authorizing a contract's code to act as another account, but not letting the contract's account act as the other account.
If you wanted to let a contract's account act as yourself but not the contract's code, you would have to do the same thing but instead of setting contract@eosio.code
you would set contract@active
or some other more specific (limited) permission.
Setting up the permission authority
To configure your account to allow contract@eosio.code
to act on your behalf, you would need to issue a transaction to the eosio::updateauth
action with the properly formatted authority data. One way to do it using cleos
is what @confused00 showed in his example:
cleos set account permission <YOUR_ACCOUNT> active '{"threshold": 1,"keys": [{"key": "<YOUR_PUBLIC_KEY>","weight": 1}],"accounts": [{"permission":{"actor":"<CONTRACT_ACCOUNT>","permission":"eosio.code"},"weight":1}]}' owner -p <YOUR_ACCOUNT>
It might be easier to save a data.json
file and then put the payload in there and point cleos
to it:
data.json
{ "threshold": 1, "keys": [ { "key": "<YOUR_PUBLIC_KEY>", "weight": 1 } ], "accounts": [ { "permission": { "actor": "<CONTRACT_ACCOUNT>", "permission": "eosio.code" }, "weight": 1 } ] }
and then:
cleos set account permission <YOUR_ACCOUNT> active data.json owner -p <YOUR_ACCOUNT>
https://eoscity.io/f/viewtopic.php?f=7&t=29
### inline action 和 eosio.code 的使用說明.
### based on v1.3.1 EOS version.
### By Chester Kuo
### 使用到的資料
### account: eoscityiobak
### Private key: 5JSm39HQThMksaCnKpCjPA8YV1qDoPKDUr4GEFLsxTxH3P4ZGvo
### Public key: EOS6QCc7maHCvmHcuv8dE159z8yttuTCcctVqZo7vq1LtJiyMELzH
### EOS 提供了一方法, 可以在一合約中(smart contract) 中去呼叫/調用另一合約 (smart contract) 中的 ACTION 動作.
### 但是為了避免因為權限過大(如使用到 active 權限是可以做轉帳功能), 又引進來 "eosio.code"這一特殊權限, 來處理合約中所需的動作(action)
### https://github.com/EOSIO/eos/issues/3013
### 底下的範例主要參考了前陣子剛推出的針對 EOS CPU 的免費及付費 CPU 租賃服務, 又有用到 inline action 的作法, 所以用這當做範例.
### https://github.com/EOSLaoMao/BankofStak ... re/mainnet
### https://github.com/chesterkuo/EOS/tree/ ... fStaked-CE
### 程式中, 有許多的 INLINE_ACTION 的使用, 透過底下的操作和程式碼交叉驗證, 應該可以讓使用者了解到 其使用方法了.
### 首先, 分別產生 ABI 和 WASM 檔案.
代碼: 選擇全部
$ eosiocpp -g src/bankofstaked.abi src/bankofstaked.cpp
WARNING: this tool is deprecated and will be removed in a future release
Please consider using the EOSIO.CDT (https://github.com/EOSIO/eosio.cdt/)
2018-10-05T08:38:49.761 thread-0 abi_generator.hpp:68 ricardian_contracts ] Warning, no ricardian clauses found for
Generated src/bankofstaked.abi ...
eos@nuceos2:/opt/eos-jungle-testnet/Other-Git/BankofStaked-CE$ eosiocpp -o src/bankofstaked.wast src/bankofstaked.c
pp
WARNING: this tool is deprecated and will be removed in a future release
Please consider using the EOSIO.CDT (https://github.com/EOSIO/eosio.cdt/)
### 利用 eoscityioeos 帳號來布署合約.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh set contract eoscityioeos src bankofstaked.wasm bankofstaked.abi
Reading WASM from src/bankofstaked.wasm...
Publishing contract...
executed transaction: cbff3ff43cbc912107b90096c03238b287923dea27e052313fa793ae59821f95 29136 bytes 6175 us
# eosio <= eosio::setcode {"account":"eoscityioeos","vmtype":0,"vmversion":0,"code":"0061736d01000000018c022860017f0060067f7f7...
# eosio <= eosio::setabi {"account":"eoscityioeos","abi":"0e656f73696f3a3a6162692f312e30001208667265656c6f636b00030b62656e656...
warning: transaction executed locally, but may not be confirmed by the network yet ]
### 根據此一合約的條件, 預先建立了二個方案, 一個是免費幫忙抵押 0.100 EOS 就可以暫時得到 0.500 EOS 的CPU 使用, 期限為360 秒, 時間過後自動取消抵押
### 另一方案是, 也是免費, 抵押 3.0 EOS 可以得 30.00 EOS CPU 的使用, 期限也是360 秒, 時間過後, EOS 自動取消抵押, 因為都是免費的方案, 所以使用者付的 EOS 都會被自動退回.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos setplan '{"price": "0.1000 EOS", "cpu": "0.5000 EOS", "net": "0.0000 EOS", "duration": 360, "is_free": true}' -p eoscityioeos
executed transaction: 12bd36bcbce51d19ada41b9aa9f775a4d10f2fa52654a6bf390d31065c279316 152 bytes 1872 us
# eoscityioeos <= eoscityioeos::setplan {"price":"0.1000 EOS","cpu":"0.5000 EOS","net":"0.0000 EOS","duration":360,"is_free":1}
warning: transaction executed locally, but may not be confirmed by the network yet ]
eos@nuceos2:/opt/eos-jungle-testnet/Other-Git/BankofStaked-CE$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos setplan '{"price": "3.0000 EOS", "cpu": "30.000 EOS", "net": "30.0000 EOS", "duration": 360, "is_free": true}' -p eoscityioeos
executed transaction: 978beeddd9ac88efee95c46b80497db58c3fc711e16d4526661fc02cc31d43b1 152 bytes 1821 us
# eoscityioeos <= eoscityioeos::setplan {"price":"3.0000 EOS","cpu":"30.000 EOS","net":"30.0000 EOS","duration":360,"is_free":1}
warning: transaction executed locally, but may not be confirmed by the network yet ]
### 查看方案表.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get table eoscityioeos eoscityioeos plan -l
{
"rows": [{
"id": 0,
"price": "0.1000 EOS",
"cpu": "0.5000 EOS",
"net": "0.0000 EOS",
"duration": 360,
"is_free": 1,
"is_active": 0,
"created_at": 1538730637,
"updated_at": 1538730637
},{
"id": 1,
"price": "3.0000 EOS",
"cpu": "30.000 EOS",
"net": "30.0000 EOS",
"duration": 360,
"is_free": 1,
"is_active": 0,
"created_at": 1538730681,
"updated_at": 1538730681
}
],
"more": false
}
"updated_at": 1538730681
}
],
"more": false
}
==============TABLE order========
{
"rows": [],
"more": false
}
------------------------------------
==============TABLE history========
{
"rows": [],
"more": false
}
------------------------------------
==============TABLE freelock========
{
"rows": [],
"more": false
}
------------------------------------
==============TABLE blacklist========
{
"rows": [],
"more": false
}
------------------------------------
==============TABLE whitelist========
{
"rows": [],
"more": false
}
------------------------------------
### 啟用此二方案.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos activateplan '{"price": "0.1000 EOS", "is_active": true}' -p eoscityioeos
executed transaction: e5366ad593b81fe09d7f38ea5706b11482aacaaf285ee972d15f3550795642b6 112 bytes 1514 us
# eoscityioeos <= eoscityioeos::activateplan {"price":"0.1000 EOS","is_active":1}
warning: transaction executed locally, but may not be confirmed by the network yet ]
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos activateplan '{"price": "3.0000 EOS", "is_active": true}' -p eoscityioeos
executed transaction: 82adfb2617b821085363ebcb18e08e63e3d3cb1e132ecf463acc3564917688e2 112 bytes 1453 us
# eoscityioeos <= eoscityioeos::activateplan {"price":"3.0000 EOS","is_active":1}
warning: transaction executed locally, but may not be confirmed by the network yet ]
代碼: 選擇全部
==============TABLE plan========
{
"rows": [{
"id": 0,
"price": "0.1000 EOS",
"cpu": "0.5000 EOS",
"net": "0.0000 EOS",
"duration": 360,
"is_free": 1,
"is_active": 1,
"created_at": 1538730637,
"updated_at": 1538730946
},{
"id": 1,
"price": "3.0000 EOS",
"cpu": "30.000 EOS",
"net": "30.0000 EOS",
"duration": 360,
"is_free": 1,
"is_active": 1,
"created_at": 1538730681,
"updated_at": 1538730960
}
],
"more": false
}
------------------------------------
### 底下的範例是說明如何新增關於"出租者" (creditor) 的資料到表單中.
### account eoscityiobak 的方案是提供免費方案的.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos addcreditor '{"account": "eoscityio123", "for_free": 0, "free_memo": ""}' -p eoscityioeos
executed transaction: 0f9722b585d4a2e2001561e6e08c1f15edadf1ff77b54d772d6bd2962ed729d4 112 bytes 2689 us
# eoscityioeos <= eoscityioeos::addcreditor {"account":"eoscityio123","for_free":0,"free_memo":""}
warning: transaction executed locally, but may not be confirmed by the network yet ]
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos addcreditor '{"account": "eoscityiobak", "for_free": 1, "free_memo": ""}' -p eoscityioeos
executed transaction: b11c64def20551eea0f831972e8c5d1a292419046fc11485371b936903ef3b91 112 bytes 1970 us
# eoscityioeos <= eoscityioeos::addcreditor {"account":"eoscityiobak","for_free":1,"free_memo":""}
>> apply 1apply 2apply 3
warning: transaction executed locally, but may not be confirmed by the network yet ]
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos activate '{"account":"eoscityio123"}' -p eoscityioeos
executed transaction: 0b7f7b889be509566210bec7334d85f855087c9f3792f8523df5d6be7b551746 104 bytes 1559 us
# eoscityioeos <= eoscityioeos::activate {"account":"eoscityio123"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh push action eoscityioeos activate '{"account":"eoscityiobak"}' -p eoscityioeos
executed transaction: 80284a780342f4c3a4d6a7502a3212677213962e92daaf1491e94c483d2ec818 104 bytes 2379 us
# eoscityioeos <= eoscityioeos::activate {"account":"eoscityiobak"}
>> apply 1apply 2apply 3
warning: transaction executed locally, but may not be confirmed by the network yet ]
代碼: 選擇全部
$ ./scripts/get_table.sh
==============TABLE creditor========
{
"rows": [{
"account": "eoscityio123",
"is_active": 1,
"for_free": 0,
"free_memo": "",
"balance": "5001.0000 EOS",
"cpu_staked": "0.0000 EOS",
"net_staked": "0.0000 EOS",
"cpu_unstaked": "0.0000 EOS",
"net_unstaked": "0.0000 EOS",
"created_at": 1538731654,
"updated_at": 1538732288
},{
"account": "eoscityiobak",
"is_active": 1,
"for_free": 1,
"free_memo": "",
"balance": "100.0000 EOS",
"cpu_staked": "0.0000 EOS",
"net_staked": "0.0000 EOS",
"cpu_unstaked": "0.0000 EOS",
"net_unstaked": "0.0000 EOS",
"created_at": 1538983818,
"updated_at": 1538983890
}
],
"more": false
}
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eoscityiobak
created: 2018-10-05T09:32:07.500
permissions:
owner 1: 1 EOS6QCc7maHCvmHcuv8dE159z8yttuTCcctVqZo7vq1LtJiyMELzH
active 1: 1 EOS6QCc7maHCvmHcuv8dE159z8yttuTCcctVqZo7vq1LtJiyMELzH
memory:
quota: 5.347 KiB used: 3.365 KiB
net bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 0 bytes
available: 18.27 MiB
limit: 18.27 MiB
cpu bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 0 us
available: 3.646 sec
limit: 3.646 sec
EOS balances:
liquid: 100.0000 EOS
staked: 200.0000 EOS
unstaking: 0.0000 EOS
total: 300.0000 EOS
producers: <not voted>
### 現在做測試, 由使用者帳號 (eosioalice22) 轉了 0.100 EOS 到了合約中, 根據設計, 合約會去找尋相對應的方案以及"出租人"是否有符合條件的人.
### 底下的錯誤訊說明了,有找到 eoscityiobak 所提供的合案, 但是並沒有相對應的權限授權給智能合約執行.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh transfer eosioalice22 eoscityioeos "0.1000 EOS" -p eosioalice22@acitve
Error 3050000: Action validate exception
Error Details:
inline action's authorizing actor does not exist
### 利用了底下的 script 來新增一權限(creditorperm) 來替 "eoscityiobak" 做代理抵押/收回抵押的資源動作 (delegatebw, undelegatebw)
代碼: 選擇全部
$ ./scripts/add_perm.sh eoscityiobak
executed transaction: 9bc618b87afa87f294ef6744ba711b3b8493b510302204744c13e869865da366 184 bytes 2384 us
# eosio <= eosio::updateauth {"account":"eoscityiobak","permission":"creditorperm","parent":"active","auth":{"threshold":1,"keys"...
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 9150adb676de8f80617fdfd91ad87f2286474c225831503d55713e52ece9404c 128 bytes 2028 us
# eosio <= eosio::linkauth {"account":"eoscityiobak","code":"eosio","type":"delegatebw","requirement":"creditorperm"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: cb51ac8299cc7343595332d6be338429a418f58395711c693a3229b8de025bef 128 bytes 1849 us
# eosio <= eosio::linkauth {"account":"eoscityiobak","code":"eosio","type":"undelegatebw","requirement":"creditorperm"}
### 針對程式中會用到的底下 INLINE ACTION, 新增了一 creditorperm 權限(permsision)
### INLINE_ACTION_SENDER(eosiosystem::system_contract, delegatebw)
### (eosio, {{creditor, N(creditorperm)}}, {creditor, beneficiary, plan->net, plan->cpu, false});
代碼: 選擇全部
$ cat scripts/add_perm.sh
=============================
#!/bin/bash
ACCOUNT=$1
PKEY=${2:-EOS5MM1wJP3cz3dkDKPXoiHzBMCwauDkcnRTjjkzFZEd9snMYDei2}
PERM_ACCOUNT=${3:-eoscityioeos}
PERMISSION=${4:-eosio.code}
API=${5:-http://localhost:8888}
CLEOS=/opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh
# example cleos set account permission your_account active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"your_contract","permission":"eosio.code"},"weight":1}]}' owner -p your_account
$CLEOS set account permission $ACCOUNT creditorperm '{"threshold": 1,"keys": [{"key": "'$PKEY'","weight": 1}],"accounts": [{"permission":{"actor":"'$PERM_ACCOUNT'","permission":"'$PERMISSION'"},"weight":1}]}' "active" -p $ACCOUNT@active
$CLEOS set action permission $ACCOUNT eosio delegatebw creditorperm -p $ACCOUNT@active
$CLEOS set action permission $ACCOUNT eosio undelegatebw creditorperm -p $ACCOUNT@active
=============================
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eoscityiobak
created: 2018-10-05T09:32:07.500
permissions:
owner 1: 1 EOS6QCc7maHCvmHcuv8dE159z8yttuTCcctVqZo7vq1LtJiyMELzH
active 1: 1 EOS6QCc7maHCvmHcuv8dE159z8yttuTCcctVqZo7vq1LtJiyMELzH
creditorperm 1: 1 EOS5DyqsEjZeukx5xJdcdowP77YuwAZ5hZ1pDs6TzPymDzYcZV31b, 1 eoscityioeos@eosio.code
memory:
quota: 5.347 KiB used: 4.008 KiB
net bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 441 bytes
available: 18.27 MiB
limit: 18.27 MiB
cpu bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 3.84 ms
available: 3.642 sec
limit: 3.646 sec
EOS balances:
liquid: 100.0000 EOS
staked: 200.0000 EOS
unstaking: 0.0000 EOS
total: 300.0000 EOS
producers: <not voted>
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eosioalice22
created: 2018-09-23T12:54:30.000
permissions:
owner 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
active 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
memory:
quota: 5.346 KiB used: 3.365 KiB
net bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 1.058 KiB
available: 18.27 MiB
limit: 18.27 MiB
cpu bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 17.45 ms
available: 3.628 sec
limit: 3.646 sec
producers: <not voted>
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh transfer eosioalice22 eoscityioeos "0.1000 EOS" -p eosioalice22@active
Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: no balance object found
pending console output:
### 因為 eosioalice22 中己經沒有可用的 EOS 了, 所以先手動轉了 100 EOS 給了 eosioalice22
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eosioalice22
created: 2018-09-23T12:54:30.000
permissions:
owner 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
active 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
memory:
quota: 5.346 KiB used: 3.365 KiB
net bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 1.058 KiB
available: 18.27 MiB
limit: 18.27 MiB
cpu bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 17.45 ms
available: 3.628 sec
limit: 3.646 sec
EOS balances:
liquid: 100.0000 EOS
staked: 200.0000 EOS
unstaking: 0.0000 EOS
total: 300.0000 EOS
producers: <not voted>
### 新增了一 permission , 以利底下程式使用.
### INLINE_ACTION_SENDER(bankofstaked, check)
### (code_account, {{code_account, N(bankperm)}}, {});
代碼: 選擇全部
$ ./scripts/set_perm.sh eoscityioeos
executed transaction: faf947f63621c1a0ca4781abeee26824e94b0744932857cee4aa04dc92f3577a 184 bytes 2212 us
# eosio <= eosio::updateauth {"account":"eoscityioeos","permission":"bankperm","parent":"active","auth":{"threshold":1,"keys":[{"...
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 3e8825aafc2da4f2756a8eb01ff6c1728b0ab1b612dac5d487c7c9af78fc522e 128 bytes 1989 us
# eosio <= eosio::linkauth {"account":"eoscityioeos","code":"eosio.token","type":"transfer","requirement":"bankperm"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 278f03181f6a13881e25095fbeefbcc7863bac7acb5a960de635e1652608e4b7 128 bytes 2070 us
# eosio <= eosio::linkauth {"account":"eoscityioeos","code":"eosio","type":"delegatebw","requirement":"bankperm"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 210e613988ab21d40e8120d7acf5cdbc6d66c34be912bb424259daf4933e28f4 128 bytes 2058 us
# eosio <= eosio::linkauth {"account":"eoscityioeos","code":"eosio","type":"undelegatebw","requirement":"bankperm"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 9b2a71fb0babbd93b9694e970a948bc24fc2511eb1fa6cde1c7ee4098d935bd1 128 bytes 1128 us
# eosio <= eosio::linkauth {"account":"eoscityioeos","code":"eoscityioeos","type":"expireorder","requirement":"bankperm"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: a1033dcca0378e31aadce85aa61ce3fa20ca55b6fb13bfa51ee40b9545f0edb2 128 bytes 844 us
# eosio <= eosio::linkauth {"account":"eoscityioeos","code":"eoscityioeos","type":"check","requirement":"bankperm"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eoscityioeos
created: 2018-08-19T04:17:19.000
permissions:
owner 1: 1 EOS5MM1wJP3cz3dkDKPXoiHzBMCwauDkcnRTjjkzFZEd9snMYDei2
active 1: 1 EOS5MM1wJP3cz3dkDKPXoiHzBMCwauDkcnRTjjkzFZEd9snMYDei2
bankperm 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV, 1 eoscityioeos@eosio.code
creditorperm 1: 1 EOS5DyqsEjZeukx5xJdcdowP77YuwAZ5hZ1pDs6TzPymDzYcZV31b, 1 eoscityioeos@eosio.code
memory:
quota: 1.169 MiB used: 921 KiB
net bandwidth:
staked: 199.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 1.609 KiB
available: 36.36 MiB
limit: 36.36 MiB
cpu bandwidth:
staked: 199.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 13.32 ms
available: 7.242 sec
limit: 7.255 sec
EOS balances:
liquid: 14878.2212 EOS
staked: 398.0000 EOS
unstaking: 0.0000 EOS
total: 15276.2212 EOS
producers:
eoscityioeos
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eosioalice22
created: 2018-09-23T12:54:30.000
permissions:
owner 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
active 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
memory:
quota: 5.346 KiB used: 3.365 KiB
net bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 1.058 KiB
available: 18.27 MiB
limit: 18.27 MiB
cpu bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 17.45 ms
available: 3.628 sec
limit: 3.646 sec
EOS balances:
liquid: 100.0000 EOS
staked: 200.0000 EOS
unstaking: 0.0000 EOS
total: 300.0000 EOS
producers: <not voted>
### 底下的例子是, eosioalice22 的帳號先轉了 0.100 EOS 到合約去, 再從 cleos 的輸出中也可以看到 有 0.5 EOS 等值的 CPU 資源從別人的帳戶中借出的.
代碼: 選擇全部
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh transfer eosioalice22 eoscityioeos "0.1000 EOS" -p eosioalice22@active
executed transaction: 1e66f3efe5429ed16b32b0be63e9787a744b189bb223df7980eaad232ed5baff 176 bytes 17519 us
# eosio.token <= eosio.token::transfer {"from":"eosioalice22","to":"eoscityioeos","quantity":"0.1000 EOS","memo":""}
# eosioalice22 <= eosio.token::transfer {"from":"eosioalice22","to":"eoscityioeos","quantity":"0.1000 EOS","memo":""}
# eoscityioeos <= eosio.token::transfer {"from":"eosioalice22","to":"eoscityioeos","quantity":"0.1000 EOS","memo":""}
>> apply 1 received token :1 received token 2 received token 3 received token 4 received token 5 received token 6 received token 7 received token 8 received token 9 received token 10 received token 11 received token 12 received token 13
# eosio <= eosio::delegatebw {"from":"eoscityiobak","receiver":"eosioalice22","stake_net_quantity":"0.0000 EOS","stake_cpu_quanti...
# eosio.token <= eosio.token::transfer {"from":"eoscityiobak","to":"eosio.stake","quantity":"0.5000 EOS","memo":"stake bandwidth"}
# eoscityiobak <= eosio.token::transfer {"from":"eoscityiobak","to":"eosio.stake","quantity":"0.5000 EOS","memo":"stake bandwidth"}
# eosio.stake <= eosio.token::transfer {"from":"eoscityiobak","to":"eosio.stake","quantity":"0.5000 EOS","memo":"stake bandwidth"}
# eoscityioeos <= eoscityioeos::check ""
>> apply 1apply 2apply 3
# eosio.token <= eosio.token::transfer {"from":"eoscityioeos","to":"eosioalice22","quantity":"0.1000 EOS","memo":""}
# eoscityioeos <= eosio.token::transfer {"from":"eoscityioeos","to":"eosioalice22","quantity":"0.1000 EOS","memo":""}
>> apply 1 received token :1
# eosioalice22 <= eosio.token::transfer {"from":"eoscityioeos","to":"eosioalice22","quantity":"0.1000 EOS","memo":""}
warning: transaction executed locally, but may not be confirmed by the network yet ]
$ /opt/eos-jungle-testnet/JungleTestnet-eoscityio123/cleos.sh get account eosioalice22
created: 2018-09-23T12:54:30.000
permissions:
owner 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
active 1: 1 EOS6sdU6tTfvJ3jkwV8NFTMPHJK5EK94zz7kWQUqHr9FLYmJD1wSv
memory:
quota: 5.346 KiB used: 3.49 KiB
net bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 177 bytes
available: 18.27 MiB
limit: 18.27 MiB
cpu bandwidth:
staked: 100.0000 EOS (total stake delegated from account to self)
delegated: 0.5000 EOS (total staked delegated to account from others)
used: 4.928 ms
available: 3.659 sec
limit: 3.664 sec
EOS balances:
liquid: 100.0000 EOS
staked: 200.0000 EOS
unstaking: 0.0000 EOS
total: 300.0000 EOS
producers: <not voted>