1.生成区块:在config.ini中添加如下:
ubuntu系统下位置
Linux: ~/.local/share/eosio/nodeos/config
config.ini genesis.json
#genesis-json = /path/to/eos/source/genesis.json
genesis-json =“genesis.json”
# Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = eosio
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
2. eosio-launcher
cd ~/eos/buildcp ~/.local/share/eosio/nodeos/config/genesis.json ././programs/eosio-launcher/eosio-launcher -p2 --skip-signature
launching bios
spawning child, programs/nodeos/nodeos --skip-transaction-signatures --config-dir etc/eosio/node_bios --data-dir var/lib/node_bios
launching testnet_00
spawning child, programs/nodeos/nodeos --skip-transaction-signatures --config-dir etc/eosio/node_00 --data-dir var/lib/node_00
launching testnet_01
spawning child, programs/nodeos/nodeos --skip-transaction-signatures --config-dir etc/eosio/node_01 --data-dir var/lib/node_01
**********************************************************************
run 'bash bios_boot.sh' to kick off delegated block production
**********************************************************************
// kick off 启动 delegated 委托
~/eos/build/programs/cleos
./cleos -p 8888 get info
./cleos -p 8889 get info
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos -p 8888 get info
{
"server_version": "124c62d0",
"head_block_num": 971,
"last_irreversible_block_num": 970,
"head_block_id": "000003cb9221843243d189be6bc3449d092e9cfd284bdcec9b7ffc2ce5692eeb",
"head_block_time": "2018-04-23T02:50:15",
"head_block_producer": "eosio"
}
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos -p 8889 get info
{
"server_version": "124c62d0",
"head_block_num": 1010,
"last_irreversible_block_num": 1009,
"head_block_id": "000003f2e39821f4b517f1332f14a73109ca7f323e28caf3f5ce0650706075d4",
"head_block_time": "2018-04-23T02:50:35",
"head_block_producer": "eosio"
}
~/eos/build/programs/eosio-launcher
root@duffy-HP-Z420-Workstation:~/eos/build/programs/eosio-launcher# ./eosio-launcher -k
terminate called after throwing an instance of 'boost::exception_detail::clone_impl >'
what(): the required argument for option '--kill' is missing
已放弃 (核心已转储)
3. Creating accounts for sample "currency.wn" contract
~/eos/build/programs/nodeos
运行:./nodeos
出现问题:
3124424ms thread-0 main.cpp:97 main ] Throw location unknown (consider using BOOST_THROW_EXCEPTION) Dynamic exception type: boost::exception_detail::clone_impl > std::exception::what: bind: Address already in use
这个时候需要:pkill nodeos
然后再 ./nodeos
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos wallet create
Error 3140001: Wallet already exists
Try to use different wallet name.
Error Details:
Wallet with name: 'default' already exists at /root/.local/share/eosio/nodeos/data/./default.wallet
文件:default.wallet
{
"cipher_keys": "0fefe3c29645d62926f22189258a5bb4b7eac1d60cb249dec2f0b07f138bd9f4e0b33c8563d3d4c733e606bf1cdf5bdd06a0224985a8d5cec487d6bc469b1de6a20b4c39ecf25b56264c36ab4503be003c1ca45163fc04fe31fdfed3ef2de7f1fbc26922998b3de3ed175a46be098770ada32730da5948f95184b9de792d9274f0d1fdb298d27c476d57492c8c19359a"
}
可以先删除default.wallet
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos wallet create
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5Hqves6ZqZoj82mFK4a3Dybu1Q2mZmTaDrA3sQBQjdGJaEJj8R9"
./cleos create key # owner-key./cleos create key # active-key
Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Public key: EOSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
currency.wn: public.owner-key+public.active-key对应一个account
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos create key
Private key: 5JEbdNgyBbbEE8o3Qq7nUbqM1UCsHCV6BdNkbmd7RXn36ucmTne
Public key: EOS6m7GxYUR2ozE6vTfiBiXUNCBWCa4SpBp9vZMXKZHpkiRmQCen4
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos create key
Private key: 5JM6aVVVV3Ku6rLCYtzmsMbMiikVKi79txPrVjWXprF3nTK62Tb
Public key: EOS64djHyrTFKk26cEMCeME81bew92DjYY1qJMA7RhTkPyCu9do5H
./cleos create account eosio currency.wn EOS6m7GxYUR2ozE6vTfiBiXUNCBWCa4SpBp9vZMXKZHpkiRmQCen4 EOS64djHyrTFKk26cEMCeME81bew92DjYY1qJMA7RhTkPyCu9do5H
3225217ms thread-0 main.cpp:1158 main ] Failed with error: Assert Exception (10)
itr != structs.end(): Unknown struct
Failed to serialize type
解决方法:Setting the bios contract first will fix this.
https://github.com/EOSIO/eos/wiki/Tutorial-Getting-Started-With-Contracts#loading-the-bios-contract
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# cleos set contract eosio ~/eos/build/contracts/eosio.bios -p eosio
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: ddcbde8c80dfa197adf3343ff5c62e2c44175d68edc70aefeefbd9677c5d1b54 3288 bytes 2200576 cycles
# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001581060037f7e7f0060057f7e7e7e7e...
# eosio <= eosio::setabi {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...
4.一个public key对应多个accounts
Private key: 5JqRJCVQvMR7b7zfn6GzdfvM4mfWCMz6xbnojENdAeMiwvQAuEm
Public key: EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
$ cleos wallet import 5JqRJCVQvMR7b7zfn6GzdfvM4mfWCMz6xbnojENdAeMiwvQAuEmimported private key for: EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
cleos create account eosio user EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
cleos create account eosio tester EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# cleos create account eosio user EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
executed transaction: 410cce74f264946b7023c9792971f825ac32d8e58f50bdd87caa402b34dde5c6 352 bytes 102400 cycles
# eosio <= eosio::newaccount {"creator":"eosio","name":"user","owner":{"threshold":1,"keys":[{"key":"EOS5iSYUbJuuJAwrabCj5kYgWDeo...
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# cleos create account eosio tester EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
executed transaction: cb84677ffcbc206637ab774186cc3e2a84f0b406d596c17d05613c39e71a7344 352 bytes 102400 cycles
# eosio <= eosio::newaccount {"creator":"eosio","name":"tester","owner":{"threshold":1,"keys":[{"key":"EOS5iSYUbJuuJAwrabCj5kYgWD...
$ cleos get accounts EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# cleos get accounts EOS5iSYUbJuuJAwrabCj5kYgWDeoWeMmSwaTYHqaVHR7x6a3vEaVY
Error 3130003: Missing Account History API Plugin
Ensure that you have eosio::account_history_api_plugin added to your node's configuration!
Error Details:
Account History API plugin is not enabled
解决:在config.ini 中补充eosio::account_history_api_plugin后,重新再来一遍
5.一个public key对应多个accounts:user1 和user2
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos create key
Private key: 5K8oq6sbNVVXbBrMu3S7J2PowuCUf7H7i6h7cEWXr2UN8nsmWHs
Public key: EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos wallet import 5K8oq6sbNVVXbBrMu3S7J2PowuCUf7H7i6h7cEWXr2UN8nsmWHs
imported private key for: EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos create account eosio user1 EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt
executed transaction: 8a6f8be005471920e17d04aba69cceacc21888c71483d0727eab904fa5fbe87c 352 bytes 102400 cycles
# eosio <= eosio::newaccount {"creator":"eosio","name":"user1","owner":{"threshold":1,"keys":[{"key":"EOS7rjYqBrYiGRAMMcPqt5WM7Em...
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos create account eosio user2 EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt
executed transaction: f876c63251ded2dfde17d6f0e8dceaa816b4fa4c39cf44d8ff2bfa5a8e7ad233 352 bytes 102400 cycles
# eosio <= eosio::newaccount {"creator":"eosio","name":"user2","owner":{"threshold":1,"keys":[{"key":"EOS7rjYqBrYiGRAMMcPqt5WM7Em...
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos get accounts EOS7rjYqBrYiGRAMMcPqt5WM7Emb6oTMxCKKmSyjc2fZK3Ux6Fupt
{
"account_names": [
"user1",
"user2"
]
}
6.将合约上传到区块链中
已有的currency
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos get account currency
{
"account_name": "currency",
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS8SFAQrfJDn76zzyTe5T3GA5wy6uqKd56Hs9CwBaCbBBYMhyRD5",
"weight": 1
}
],
"accounts": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS6S8i2NrsHUK4jH4hpmufvaxeCNudenvjB8NSY6n8xmw9ZJhGUb",
"weight": 1
}
],
"accounts": []
}
}
]
}
7.上传currency.wn
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos set contract currency.wn ~/eos/build/contracts/currency -p currency
Reading WAST...
Assembling WASM...
Publishing contract...
Error 3030002: signatures do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and you wallet is unlocked.
Error Details:
transaction declares authority '{"actor":"currency","permission":"active"}', but does not have signatures for it.
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos set contract currency.wn ../../contracts/currency
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: 3ad63afacacc8b4a2b75b53bd4716f5b18507ff36833c465c77731e8fc741d93 7112 bytes 2200576 cycles
# eosio <= eosio::setcode {"account":"currency.wn","vmtype":0,"vmversion":0,"code":"0061736d010000000199011860000060027e7e0060...
# eosio <= eosio::setabi {"account":"currency.wn","abi":{"types":[{"new_type_name":"account_name","type":"name"}],"structs":[...
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos get code currency.wn
code hash: d6c891fbdfcff597d82e17c81354574399b01d533e53d412093f03e1950fb9d4
创建货币:
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos push action currency.wn create '{"issuer":"currency.wn","maximum_supply":"1000000.0000 CUR","can_freeze":"0","can_recall":"0","can_whitelist":"0"}' --permission currency.wn@active
executed transaction: 4a60b5351379eb96ba6a1b01cf70fa3c4ee4f059372d21e20b289fd095c0cb2e 248 bytes 103424 cycles
# currency.wn <= currency.wn::create {"issuer":"currency.wn","maximum_supply":"1000000.0000 CUR","can_freeze":0,"can_recall":0,"can_white...
>> create
发行货币:
./cleos push action currency.wn issue '{"to":"currency.wn","quantity":"1000.0000 CUR","memo":""}' --permission currency.wn@active
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos push action currency.wn issue '{"to":"currency.wn","quantity":"1000.0000 CUR","memo":""}' --permission currency.wn@active
executed transaction: 549f638a1f6011b1662942998a94bbb7f24797fbcac0667c77213f769e296cc9 248 bytes 106496 cycles
# currency.wn <= currency.wn::issue {"to":"currency.wn","quantity":"1000.0000 CUR","memo":""}
>> issue
查看账户信息:
./cleos get table currency.wn currency.wn accounts
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos get table currency.wn currency.wn accounts
{
"rows": [{
"balance": "1000.0000 CUR",
"frozen": 0,
"whitelist": 1
}
],
"more": false
}
转账:
$ ./cleos push action currency.wn transfer '{"from":"currency.wn","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency.wn@active
$ ./cleos get table currency.wn currency.wn accounts
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos push action currency.wn transfer '{"from":"currency.wn","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency.wn@active
executed transaction: 5327a00416bf3a2c58b2b0396b199010209955ee439ac066716ddc695bd1f106 272 bytes 109568 cycles
# currency.wn <= currency.wn::transfer {"from":"currency.wn","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}
>> transfer
# eosio <= currency.wn::transfer {"from":"currency.wn","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos# ./cleos get table currency.wn currency.wn accounts
{
"rows": [{
"balance": "980.0000 CUR",
"frozen": 0,
"whitelist": 1
}
],
"more": false
}
8.eosio.token上传
private key: 5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR
public key: EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos wallet import 5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR
imported private key for: EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos create account eosio eosio.token EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
executed transaction: 02e589809f6c0728c49050f87c5eca2c1cdc6f57096161297000ff880a3ad353 352 bytes 102400 cycles
# eosio <= eosio::newaccount {"creator":"eosio","name":"eosio.token","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7D...
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#cleos get accounts EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
{
"account_names": [
"eosio.token"
]
}
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos get account eosio.token
{
"account_name": "eosio.token",
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4",
"weight": 1
}
],
"accounts": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4",
"weight": 1
}
],
"accounts": []
}
}
]
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos set contract eosio.token ~/eos/build/contracts/eosio.token -p eosio.token
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: f0410a4b03233b65d631a53e0f941b2080b95b32d032a8dec25c2d3fde5f83a8 8024 bytes 2200576 cycles
# eosio <= eosio::setcode {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d01000000018a011660067f7e7f7f7f7f00...
# eosio <= eosio::setabi {"account":"eosio.token","abi":{"types":[],"structs":[{"name":"transfer","base":"","fields":[{"name"...
root@duffy-HP-Z420-Workstation:~/eos/build/programs/cleos#./cleos get code eosio.token
code hash: 7c6a300874835ad928de4f30712023758157bd50cb423ab039443f56a84167ff