Resources

There are 2 types of FIBOS Resources: one is mortgage type resources, includes CPU and NET; the other one is a consumption resource, called RAM or storage.

Enough RAM,CPU and NET are required if a user wants to release a contract.

RAM and Resources

RAM

Network Bandwidth

CPU Bandwidth

How to buy or mortgage resources

Buy RAM

  1. RAM consumption is required to store account information on chain, thus the creator needs to buy RAM for the user to save new account information.

    This is done by by calling the buyrambytes method. The parameters and explanation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const FIBOS = require('fibos.js');

const fibos_client = FIBOS({
// fibos test net chainId
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'your private key',
httpEndpoint: "http://api.testnet.fo",
});

let ctx = fibos_client.contractSync('eosio');

var r = ctx.buyrambytesSync({
payer: "fibosmaster1", //creator account name
receiver: "yunyu1212122", //receiver account name
bytes: 4096 //size of RAM to buy
},{
authorization: 'account correspoding to private key'
});
console.log(r);
  1. Buy storage resources. The difference is to buy specific amount of tokens or specific size of content.

By calling buyram method. The parameters and explanation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const FIBOS = require('fibos.js');

const fibos_client = FIBOS({
// fibos test net chainId
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'your private key',
httpEndpoint: "http://api.testnet.fo",
});

let ctx = fibos_client.contractSync('eosio');

var r = ctx.buyramSync({
payer: "silver123451", //payer account
receiver: "silver123451", //receiver account
quant: "0.1273 FO" //token amount to buy storage resources
},{
authorization: 'account correspoding to private key'
});
console.log(r);

Mortgage Resources

Creator mortgages FO for receiver to get CPU and NET in order to let new account be able to transfer.

By calling delegatebw method, the parameters and explain are as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const FIBOS = require('fibos.js');

const fibos_client = FIBOS({
// fibos test net chainId
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'your private key',
httpEndpoint: "http://api.testnet.fo",
});

let ctx = fibos_client.contractSync('eosio');

var r = ctx.delegatebwSync({
from: "slowmistioio", //mortgager account
receiver: "slowmistioio", //receiver account
stake_net_quantity: "3193.0000 FO", //mortgage FO to get NET
stake_cpu_quantity: "30000.0000 FO", // mortgage FO to get CPU
transfer: 0 // whether transfer the token to receiver while mortgaing resources
},{
authorization: 'account correspoding to private key'
});
console.log(r);

Cancel Mortgage

Used to cancel mortgaging, release resources and get token back.

By calling updelegatebw method, the parameters and explain are as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const FIBOS = require('fibos.js');

const fibos_client = FIBOS({
// fibos test net chainId
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'your private key',
httpEndpoint: "http://api.testnet.fo",
});

let ctx = fibos_client.contractSync('eosio');

var r = ctx.undelegatebwSync({
from: 'hoffercq1211', //Remove the mortgage with which account
receiver: 'hoffercq1211', //Lift the role in which account of the mortgage
unstake_net_quantity: '649540.0000 FO', //Lift the token amount used to obtain bandwidth resources
unstake_cpu_quantity: '649540.0000 FO' //Lift the token amount used to gain access to computing resources
},{
authorization: 'account correspoding to private key'
});
console.log(r);

Sell Resources

By calling sellram method, the parameters and explaination are as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const FIBOS = require('fibos.js');
require('ssl').loadRootCerts();

const client = FIBOS({
// fibos test net chainId
chainId: '68cee14f598d88d340b50940b6ddfba28c444b46cd5f33201ace82c78896793a',
keyProvider: 'your private key',
httpEndpoint: "http://api.testnet.fo",
});

let ctx = fibos_client.contractSync('eosio');

var r = ctx.sellramSync({
account: "silver123451", //seller account
bytes: 789438000 //size of storage resource to be sold
},{
authorization: 'account correspoding to private key'
});
console.log(r);