-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_account.sh
More file actions
executable file
·52 lines (40 loc) · 1.08 KB
/
create_account.sh
File metadata and controls
executable file
·52 lines (40 loc) · 1.08 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
#!/bin/sh
# Creates a new EOS account for a specified wallet.
if [ ! $# -eq 3 ]; then
echo "Usage: $0 <account> <wallet> <wallet url>"
exit 1
fi
ACCOUNT=$1
WALLET=$2
URL=$3
CLEOSCMD="cleos --wallet-url ${URL}"
function check_exit() {
if [ ! $? -eq 0 ]; then
exit $?
fi
}
# Takes private key.
function import_key() {
${CLEOSCMD} wallet import $1 -n ${WALLET}
check_exit
}
echo "Creating keys.."
RET=$(${CLEOSCMD} create key)
OWNER_PRIVKEY=$(echo ${RET} | awk '{print $3;}')
OWNER_PUBKEY=$(echo ${RET} | awk '{print $6;}')
RET=$(${CLEOSCMD} create key)
ACTIVE_PRIVKEY=$(echo ${RET} | awk '{print $3;}')
ACTIVE_PUBKEY=$(echo ${RET} | awk '{print $6;}')
echo "\n[OWNER]"
echo "Privkey: ${OWNER_PRIVKEY}"
echo "Pubkey: ${OWNER_PUBKEY}"
echo "\n[ACTIVE]"
echo "Privkey: ${ACTIVE_PRIVKEY}"
echo "Pubkey: ${ACTIVE_PUBKEY}"
echo "\nImporting private keys into ${WALLET} wallet.."
import_key ${OWNER_PRIVKEY}
import_key ${ACTIVE_PRIVKEY}
echo "\nCreating account ${ACCOUNT}.."
${CLEOSCMD} create account eosio ${ACCOUNT} ${OWNER_PUBKEY} ${ACTIVE_PUBKEY}
check_exit
echo "Success!"