-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (108 loc) · 4.56 KB
/
Makefile
File metadata and controls
134 lines (108 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
cleos = docker exec -it eosio /opt/eosio/bin/cleos --url http://127.0.0.1:7777 --wallet-url http://127.0.0.1:5555
CONTRACT_FOLDER ?= $(CURDIR)/contracts
DEV_PRIVATE_KEY ?= 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
DEV_PUBLIC_KEY ?= EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
WALLET_PRIVATE_KEY ?= PW5KaNqnMu6fxMCThhK92fnKq7HuW9RW54FrZpz22YYWadV5GVc9a
WALLET_PUBLIC_KEY ?= EOS6PZ7uYhNi9gryXHF9yR15C6f8TiNu5QAcnKdCqPvzNVoPDR62Y
clean:
docker rm -f eosio
eos:
mkdir -p $(CURDIR)/contracts
docker run --rm --name eosio \
--publish 7777:7777 \
--publish 127.0.0.1:5555:5555 \
--volume $(CONTRACT_FOLDER):$(CONTRACT_FOLDER) \
--detach \
eosio/eos:v1.4.1 \
/bin/bash -c \
"keosd --http-server-address=0.0.0.0:5555 & \
exec nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--plugin eosio::http_plugin \
-d /mnt/dev/data \
--config-dir /mnt/dev/config \
--http-server-address=0.0.0.0:7777 \
--access-control-allow-origin=* \
--contracts-console \
--http-validate-host=false \
--filter-on='*'"
list:
@$(cleos) wallet list
create:
@$(cleos) wallet create --to-console
# set WALLET_PRIVATE_KEY
@$(cleos) wallet open
unlock:
@$(cleos) wallet unlock --password $(WALLET_PRIVATE_KEY)
@$(cleos) wallet create_key
# set WALLET_PUBLIC_KEY
@$(cleos) wallet import --private-key $(DEV_PRIVATE_KEY)
account:
$(cleos) create account eosio bob $(WALLET_PUBLIC_KEY)
$(cleos) create account eosio alice $(WALLET_PUBLIC_KEY)
$(cleos) create account eosio caller $(WALLET_PUBLIC_KEY)
$(cleos) create account eosio receiver $(WALLET_PUBLIC_KEY)
$(cleos) create account eosio hello $(WALLET_PUBLIC_KEY) -p eosio@active
$(cleos) create account eosio addressbook $(WALLET_PUBLIC_KEY) -p eosio@active
$(cleos) create account eosio abcounter $(WALLET_PUBLIC_KEY) -p eosio@active
define build
cd $(CONTRACT_FOLDER)/$(1); \
eosio-cpp -o $(1).wasm $(1).cpp --abigen; \
$(cleos) set contract $(1) $(CONTRACT_FOLDER)/$(1); \
cd -
endef
hello:
$(call build,hello)
$(cleos) push action hello hi '["bob"]' -p bob@active
$(cleos) push action hello hi '["alice"]' -p alice@active
define grant
@$(cleos) set account permission $(1) active \
'{"threshold": 1,"keys": [{"key": "$(WALLET_PUBLIC_KEY)", "weight": 1}], "accounts": [{"permission":{"actor":"$(2)","permission":"eosio.code"},"weight":1}]}' \
owner -p $(1)@owner
endef
caller:
$(call build,caller)
$(call build,receiver)
$(call grant,alice,caller)
$(cleos) push action caller hi '["bob", "alice"]' -p bob@active
ab:
$(call build,abcounter)
ab.by.count:
$(cleos) get table abcounter abcounter counts --lower alice --limit 2
addr:
$(call build,addressbook)
$(call grant,addressbook,addressbook)
$(cleos) push action addressbook upsert '["bob", "bob", "is a guy", 50, "doesnt exist", "somewhere", "someplace"]' -p bob@active
$(cleos) push action addressbook upsert '["alice", "alice", "liddell", 9, "123 drink me way", "wonderland", "amsterdam"]' -p alice@active
addr.clean:
$(cleos) push action addressbook erase '["bob"]' -p bob@active
$(cleos) push action addressbook erase '["alice"]' -p alice@active
addr.by.name:
$(cleos) get table addressbook addressbook people --lower alice --limit 1
addr.by.age:
$(cleos) get table addressbook addressbook people --upper 10 --key-type i64 --index 2
$(cleos) get table addressbook addressbook people --upper 50 --key-type i64 --index 2
# $(cleos) get table addressbook addressbook people -h
addr.list:
$(cleos) get actions alice
token.account:
$(cleos) create account eosio eosio.token $(DEV_PUBLIC_KEY)
token.build:
cd $(CONTRACT_FOLDER)/eosio.contracts/eosio.token; \
eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp --abigen; \
$(cleos) set contract eosio.token $(CONTRACT_FOLDER)/eosio.contracts/eosio.token --abi eosio.token.abi -p eosio.token@active; \
cd -
token.create:
$(cleos) push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active
$(cleos) push action eosio.token create '{"issuer":"eosio", "maximum_supply":"1000000000.0000 SYS"}' -p eosio.token@active
token.issue:
$(cleos) push action eosio.token issue '[ "alice", "100.0000 SYS", "memo" ]' -p eosio@active
$(cleos) push action eosio.token issue '["alice", "100.0000 SYS", "memo"]' -p eosio@active -d -j
token.transfer:
$(cleos) push action eosio.token transfer '[ "alice", "bob", "25.0000 SYS", "m" ]' -p alice@active
token.get:
$(cleos) get currency balance eosio.token bob SYS
$(cleos) get currency balance eosio.token alice SYS