Guidelines
- Introduction
- Installation
- Quick Start
Guides
- Introductions
- Build local test node
- Smart Contract - ABI Files
- Smart Contract——JS Contract
- Deploy Contracts
- Test Contract
- Develop DApp Client
Smart Contracts
- Contract Introduction
- ABI File
- Database
- Account Authority
- Call In-contract
- Notification
System Contracts
- Resources
- Account
- Permission
Token Contracts
- Transfer
- Token
- Token Exchange
- Contract Sub-Wallet
Node Guide
- Node Introduction
- Add to nodes network
- Node Data Persistence
Access Guide
- FO 接入安全指南
Quick Start
Building a FIBOS development environment requires installation of fibos and fibos.js.
For installation proccess please see to 【Quick Installation】.
The directory structure of the code example in this section is as follows:
1 | hello_fibos/ |
Find the sample code in this chapter here : https://github.com/FIBOSIO/samples under the basic
folder.
Start Node
Environment configuration script
Create start_fibos
folder and save the codes to node.js
1 | var fibos = require('fibos'); |
Run the FIBOS development environment:
1 | hello_fibos$ fibos start_fibos/node.js |
Run results log (part):
1 | …… |
If you see the above message, it means operation is sucessful and fibos
has started block production.
JavaScript Contract Code
Note: A new window is required to ensure that node,js is operating normally.
Create folder fibos_client
,and save the following code to hello/hello.js
:
1 | exports.hi = user => console.error('in contract:', user); |
Contract ABI file
Save the following code to hello/hello.abi
:
1 | { |
Connect to FIBOS node
Create a new initClient.js
under the folder of fibos_client
, and save the following code:
1 | var FIBOS = require('fibos.js'); |
Load and publish contract scripts
Create deploy.js
under the folder of fibos_client
, and save the following code:
1 | var FIBOS = require('./initClient.js') |
Run the script:
1 | hello_fibos$ fibos fibos_client/deploy.js |
Output the results (part):
1 | code: { |
Notes: wasm
is a kind of low-level and easy bytecode that is designed to achieve near-native execution speed.
Call the contract
Use the API in fibos.js to call the contract.
Create call.js
under the folder of fibos_client
, and save the following code:
1 | var FIBOS = require('./initClient.js') |
Execute the scripts:
1 | hello_fibos$ fibos fibos_client/call.js |
Printed results by Console are as follows:
1 | { |
At the same time, the FIBOS node service console displays the trxs:1
, and the displayed results are as follows:1
2018-8-30T14:28:22.005 thread-1 producer_plugin.cpp:1196 produce_block ] Produced block 00000e57c573a33b... #3671 @ 2018-07-30T14:28:22.000 signed by eosio [trxs: 1, lib: 3670, confirmed: 0]
This chapter gives you a quick understanding of JavaScript contract and a simple JavaScript contract. There is an example for you in the 【Instructions】.