OnBlock
ToDo
- What is OnBlock integration? Who is the audience?
- Provide fully working example of an OnBlock integration.
What is the OnBlock Integration?
OnBlock provides features and functions for two distinct groups of users:
- One is for the end user. OnBlock allows for easy account creation on the IOST blockchain and
- Two is for developers. The OnBlock SDK gives developers all the tools required to create accounts, allocate resources such as iGAS and iRAM, and on board new users to their dapp.
Benefits for the end user to easily create an account on IOST which allows the user to access dapps. For instance, Joe wants to play the Herorats game but finds that creating the IOST account requires knowledge of iRAM, iGAS, and he needs to visit multiple websites to set this up. Only then can Joe play Herorats. OnBlock allows Joe a single location to create the account and immediately play the game.
The second function is for developers. As an example, the developer of Herorats used the OnBlock SDK to integrate the IOST currency into their game. No need to create user accounts, deal with password resets, or cryptocurrency wallets.
(link to http://developers1.onblock.me/docs/en/introduce/ and remove text)
OnBlock JavaScript SDK
OnBlock.js
OnBlock.js
OnBlock.js provided the basic API with OnBlock
isInOnBlock
Determine whether it is on OnBlock or not.
Parameters
Name | Type | Description |
---|---|---|
url | String | onblock url,Default https://onblock.me |
Return
Booleam true/false true means it is on OnBlock, false means it is not on OnBlock
For example
const isOnBlock = OnBlock.isInOnBlock()
// const isOnBlock = OnBlock.isInOnBlock('http://testnet.onblock.me')
enable
obtain username method
Return
Promise returns username (OID)
For example
OnBlock.enable().then(name => {
console.log(name)
})
getOnBlockAccountInfo
Get OnBlock Account Information
Return
Promise returns Account Balance List
Name | Type | Description |
---|---|---|
id | Number | ID |
chain | String | Chain |
symbol | String | Token |
available | String | Available Asset |
freeze | String | Frozen Asset |
For example
OnBlock.getOnBlockAccountInfo().then(data => {
// data sample:
// [
// {id: 1, chain: 'iost', symbol: 'iost', available: '0', freeze: '0'},
// {id: 2, chain: 'iost', symbol: 'iet', available: '0', freeze: '0'},
// {id: 2, chain: 'iost', symbol: 'your token', available: '0', freeze: '0'}
// ]
})
account
Obtain account information
Return
Object account information
Name | Type | description |
---|---|---|
name | String | OID |
OAA | String | IOSTOAA |
EosOAA | String | EosOAA |
network | String | chain information |
type | String | platform information |
For example
const user = OnBlock.account
{name: 'xxx', OAA: 'xxx', EosOAA: 'xxx', network: 'MAINNET', type: 'onblock'}
newIOST
Create an iost instance, please refer IOST frontend for more.
Find IOST user guide in IOST document.