Account

Tips: We will close free FIBOS account register channel on Sep 4th. After then, users who want to register FIBOS account can ask the users that already have FIBOS account to help you to register via learning this document.

What is account

Generate public/private key

Tips: The private key generated needs to be saved properly, and make sure it is not leaked to anyone! Registering a FIBOS account by someone else only requires your public key. Anyone who ask for your private key for the reason of helping you to register a FIBOS account are fraudsters.

Generate by ecc of fibos.js

1
2
3
4
var FIBOS = require('fibos.js');
var prikey = FIBOS.modules.ecc.randomKeySync(); //private key
var pubkey = FIBOS.modules.ecc.privateToPublic(prikey); //public key
console.log('public key: %s\nprivate key: %s',pubkey,prikey);

Create Account

create new account

newaccount method and parameters:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var FIBOS = require('fibos.js');
var fibos_client = FIBOS({
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'creator_priKey',
httpEndpoint: 'http://api.testnet.fo',
logger: {
log: null,
error: null
}
});

fibos_client.newaccount({
creator: "Creator Name", //Creator acount name
name: "Account Name", //Created account name
owner: "Owner Key", //Created owner permission public key
active: "Active Key" //Created active permission public key
});

Buy RAM

Saving account information to the chain consumes RAM. The creator needs to buy RAM for the created account informations.

buyrambytes method and parameters:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var FIBOS = require('fibos.js');
var fibos_client = FIBOS({
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'creator_priKey',
httpEndpoint: 'http://api.testnet.fo',
logger: {
log: null,
error: null
}
});

fibos_client.buyrambytes({
payer: 'eosio.token',//Created account name
receiver: 'Receiver Account',//Created account name
bytes: 4096 //The amount of memory consumed
});

Mortgage Resources

Creator mortgages FO to get CPU and NET to allow the created account to do transfers.

delegatebw method and parameters:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var FIBOS = require('fibos.js');
var fibos_client = FIBOS({
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'creator_priKey',
httpEndpoint: 'http://api.testnet.fo',
logger: {
log: null,
error: null
}
});

fibos_client.delegatebw({
from: 'from',//Creator account name
receiver: 'Your_Account',//Created account name
stake_net_quantity: '0.1000 FO',//Creator mortgage FO to get CPU for created account
stake_cpu_quantity: '0.1000 FO',//Creator mortgage FO to get NET for created account
transfer: 1//Represents wether to transfer tokens to receivors while mortgaging resources
});

Example

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
var FIBOS = require('fibos.js');
var fibos_client = FIBOS({
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'creator_priKey',
httpEndpoint: 'http://api.testnet.fo',
logger: {
log: null,
error: null
}
});
var r = fibos_client.transactionSync(tr => {
tr.newaccount({
creator: 'creator_account',
name: 'your_account',
owner: 'your_owner_publicKey',
active: 'your_active_publicKey'
});
tr.buyrambytes({
payer: 'creator_account',
receiver: 'your_account',
bytes: 4096
});
tr.delegatebw({
from: 'creator_account',
receiver: 'your_account',
stake_net_quantity: '0.1000 FO',
stake_cpu_quantity: '0.1000 FO',
transfer: 1
});
});
console.log(r);

Execute the code to help others successfully register an account.

Results (parts) :

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
'act': {
'account': 'eosio',
'name': 'newaccount',
'authorization': [{
'actor': 'fibostest123',
'permission': 'active'
}],
'data': {
'creator': 'fibostest123',
'name': 'xinchengdai1',
'owner': {
'threshold': 1,
'keys': [{
'key': 'FO7yLv8FvFhFCjajcqgnJJFHBUnLLS9BYfZLymQXoDu7wL3a67Xr',
'weight': 1
}],
'accounts': [],
'waits': []
},
'active': {
'threshold': 1,
'keys': [{
'key': 'FO7yLv8FvFhFCjajcqgnJJFHBUnLLS9BYfZLymQXoDu7wL3a67Xr',
'weight': 1
}],
'accounts': [],
'waits': []
}
},

Based on the information printed above,We can see fibostest123 account created an account named xinchengdai1 ,next the owner of account xinchengdai1 can import the private key to FO wallet to use the other functions! click download FO wallet to get FO wallet.