Skip to content

Commit

Permalink
Create new account.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuelongqy committed Oct 28, 2021
1 parent 27fbe1b commit 45e16c3
Show file tree
Hide file tree
Showing 2 changed files with 220 additions and 0 deletions.
76 changes: 76 additions & 0 deletions example/new_account.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:eosdart/eosdart.dart';

main() {
EOSClient client = EOSClient('https://jungle3.cryptolions.io', 'v1', privateKeys: ["5J9b3xMkbvcT6gYv2EpQ8FD4ZBjgypuNKwE1jxkd7Wd1DYzhk88"]);

//privateKeys can also be set after client was constructed, as following
//client.privateKeys = ["5J9b3xMkbvcT6gYv2EpQ8FD4ZBjgypuNKwE1jxkd7Wd1DYzhk88"];

List<Authorization> auth = [
Authorization()
..actor = 'xuelongqy2cn'
..permission = 'active'
];

Map data = {
'creator': 'xuelongqy2cn',
'name': 'xuelongqy3cn',
'owner': {
'threshold': 1,
'keys': [
{
'key': "EOS65xaKR6zw4cjy9kuwuCbi7vTTbWNYSHdVgNf7492VAjCPi6gT6",
'weight': 1,
}
],
'accounts': [],
'waits': []
},
'active': {
'threshold': 1,
'keys': [
{
'key': "EOS65xaKR6zw4cjy9kuwuCbi7vTTbWNYSHdVgNf7492VAjCPi6gT6",
'weight': 1,
}
],
'accounts': [],
'waits': []
},
};

List<Action> actions = [
Action()
..account = 'eosio'
..name = 'newaccount'
..authorization = auth
..data = data,
Action()
..account = 'eosio'
..name = 'buyram'
..authorization = auth
..data = {
'payer': "xuelongqy2cn",
'receiver': "xuelongqy3cn",
'quant': "2.0000 EOS",
},
Action()
..account = 'eosio'
..name = 'delegatebw'
..authorization = auth
..data = {
'from': "xuelongqy2cn",
'receiver': "xuelongqy3cn",
'stake_net_quantity': "1.0000 EOS",
'stake_cpu_quantity': "1.0000 EOS",
'transfer': false,
}
];

Transaction transaction = Transaction()..actions = actions;

// print result
client.pushTransaction(transaction, broadcast: true).then((trx) {
print(trx);
});
}
144 changes: 144 additions & 0 deletions lib/src/jsons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,150 @@ String abiJson = '''
}
]
},
{
"name": "newaccount",
"base": "",
"fields": [
{
"name": "creator",
"type": "name"
},
{
"name": "name",
"type": "name"
},
{
"name": "owner",
"type": "authority"
},
{
"name": "active",
"type": "authority"
}
]
},
{
"name": "authority",
"base": "",
"fields": [
{
"name": "threshold",
"type": "uint32"
},
{
"name": "keys",
"type": "key_weight[]"
},
{
"name": "accounts",
"type": "permission_level_weight[]"
},
{
"name": "waits",
"type": "wait_weight[]"
}
]
},
{
"name": "key_weight",
"base": "",
"fields": [
{
"name": "key",
"type": "public_key"
},
{
"name": "weight",
"type": "uint16"
}
]
},
{
"name": "permission_level_weight",
"base": "",
"fields": [
{
"name": "permission",
"type": "permission_level"
},
{
"name": "weight",
"type": "uint16"
}
]
},
{
"name": "wait_weight",
"base": "",
"fields": [
{
"name": "wait_sec",
"type": "uint32"
},
{
"name": "weight",
"type": "uint16"
}
]
},
{
"name": "permission_level",
"base": "",
"fields": [
{
"name": "actor",
"type": "name"
},
{
"name": "permission",
"type": "name"
}
]
},
{
"name": "buyram",
"base": "",
"fields": [
{
"name": "payer",
"type": "name"
},
{
"name": "receiver",
"type": "name"
},
{
"name": "quant",
"type": "asset"
}
]
},
{
"name": "delegatebw",
"base": "",
"fields": [
{
"name": "from",
"type": "name"
},
{
"name": "receiver",
"type": "name"
},
{
"name": "stake_net_quantity",
"type": "asset"
},
{
"name": "stake_cpu_quantity",
"type": "asset"
},
{
"name": "transfer",
"type": "bool"
}
]
},
{
"name": "type_def",
"base": "",
Expand Down

0 comments on commit 45e16c3

Please sign in to comment.