# GXClient
# Classes
- GXClient
GXClient Class
# Typedefs
- signatureProvider :
function
This callback is displayed as a global member.
# GXClient
GXClient Class
Kind: global class
- GXClient
- new GXClient(private_key, account_id_or_name, entry_point, signProvider)
- .generateKey() ⇒
Object
- .privateToPublic(privateKey) ⇒
String
- .isValidPublic(publicKey) ⇒
boolean
- .isValidPrivate(privateKey) ⇒
boolean
- .register(account, activeKey, ownerKey, memoKey, faucet) ⇒
Promise.<any>
- .getObject(object_id) ⇒
Request
|PromiseLike.<T>
|Promise.<T>
- .getObjects(object_ids) ⇒
Request
|PromiseLike.<T>
|Promise.<T>
- .getAccount(account_name) ⇒
Promise.<any>
- .getChainID() ⇒
Request
|PromiseLike.<T>
|Promise.<T>
- .getDynamicGlobalProperties() ⇒
Request
|PromiseLike.<T>
|Promise.<T>
- .getAccountByPublicKey(publicKey) ⇒
Request
|PromiseLike.<T>
|Promise.<T>
- .getAccountBalances(account_name) ⇒
Promise.<any>
- .getAsset(symbol) ⇒
Promise.<any>
- .getBlock(blockHeight) ⇒
Promise.<any>
- .detectTransaction(blockHeight, callback)
- .transfer(to, memo, amount_asset, broadcast, options) ⇒
Promise.<any>
- .getStakingPrograms()
- .createStaking(to, amount, program_id, options) ⇒
Promise.<any>
- .updateStaking(to, staking_id, options) ⇒
Promise.<any>
- .claimStaking(to, staking_id, options) ⇒
Promise.<any>
- .getContractABI(contract_name) ⇒
Promise.<any>
- .getContractTable(contract_name) ⇒
Promise.<any>
- .getTableObjects(contract_name, table_name, start, limit) ⇒
Promise.<any>
- .getTableObjectsEX(contract_name, table_name, lower_bound, upper_bound, limit, reverse) ⇒
*
- .createContract(contract_name, code, abi, vm_type, vm_version, broadcast, options) ⇒
Promise.<any>
- .updateContract(contract_name, newOwner, code, abi, broadcast, options) ⇒
Request
|PromiseLike.<T>
|Promise.<T>
- .callContract(contract_name, method_name, params, amount_asset, broadcast, options) ⇒
Promise.<any>
- .vote(accounts, broadcast, options) ⇒
Promise.<any>
- .fee(operation, feeAssetId) ⇒
Promise.<any>
- .broadcast(tx) ⇒
Promise.<any>
# new GXClient(private_key, account_id_or_name, entry_point, signProvider)
Param | Type | Default | Description |
---|---|---|---|
private_key | String | private key | |
account_id_or_name | String | e.g: '1.2.44' | |
entry_point | String | wss://node1.gxb.io | entry point network address |
signProvider | signatureProvider |
|
# gxClient.generateKey() ⇒ Object
generate key pair locally
Kind: instance method of GXClient
# gxClient.privateToPublic(privateKey) ⇒ String
export public key from private key
Kind: instance method of GXClient
Param | Type |
---|---|
privateKey | String |
# gxClient.isValidPublic(publicKey) ⇒ boolean
check if public key is valid
Kind: instance method of GXClient
Param | Type |
---|---|
publicKey | String |
# gxClient.isValidPrivate(privateKey) ⇒ boolean
check if private key is valid
Kind: instance method of GXClient
Param | Type |
---|---|
privateKey | String |
# gxClient.register(account, activeKey, ownerKey, memoKey, faucet) ⇒ Promise.<any>
register an account by faucet
Kind: instance method of GXClient
Param | Type | Default | Description |
---|---|---|---|
account | String | Account name | |
activeKey | String | Public Key for account operator | |
ownerKey | String | Public Key for account owner | |
memoKey | String | Public Key for memo | |
faucet | String | https://opengateway.gxb.io | faucet url |
Example
curl ‘https://opengateway.gxb.io/account/register' -H 'Content-type: application/json' -H 'Accept: application/json’ -d ‘{“account”:{“name”:”gxb123”,”owner_key”:”GXC5wQ4RtjouyobBV57vTx7boBj4Kt3BUxZEMsUD3TU369d3C9DqZ”,”active_key”:”GXC7cPVyB9F1Pfiaaxw4nY3xKADo5993hEsTjFs294LKwhqsUrFZs”,”memo_key”:”GXC7cPVyB9F1Pfiaaxw4nY3xKADo5993hEsTjFs294LKwhqsUrFZs”,”refcode”:null,”referrer”:null}}’
# gxClient.getObject(object_id) ⇒ Request
| PromiseLike.<T>
| Promise.<T>
get object by id
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
object_id | String | e.g: '1.2.3' |
# gxClient.getObjects(object_ids) ⇒ Request
| PromiseLike.<T>
| Promise.<T>
get objects
Kind: instance method of GXClient
Param | Type |
---|---|
object_ids | Array.<String> |
# gxClient.getAccount(account_name) ⇒ Promise.<any>
get account info by account name
Kind: instance method of GXClient
Param | Type |
---|---|
account_name | String |
# gxClient.getChainID() ⇒ Request
| PromiseLike.<T>
| Promise.<T>
get current blockchain id
Kind: instance method of GXClient
# gxClient.getDynamicGlobalProperties() ⇒ Request
| PromiseLike.<T>
| Promise.<T>
get dynamic global properties
Kind: instance method of GXClient
# gxClient.getAccountByPublicKey(publicKey) ⇒ Request
| PromiseLike.<T>
| Promise.<T>
get account_ids by public key
Kind: instance method of GXClient
Param | Type |
---|---|
publicKey | String |
# gxClient.getAccountBalances(account_name) ⇒ Promise.<any>
get account balances by account name
Kind: instance method of GXClient
Param | Type |
---|---|
account_name | String |
# gxClient.getAsset(symbol) ⇒ Promise.<any>
get asset info by symbol
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
symbol | String | e.g: 'GXC' |
# gxClient.getBlock(blockHeight) ⇒ Promise.<any>
get block by block height
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
blockHeight | Number | block height |
# gxClient.detectTransaction(blockHeight, callback)
detect new transactions related to this.account_id
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
blockHeight | Number | block height |
callback | function |
# gxClient.transfer(to, memo, amount_asset, broadcast, options) ⇒ Promise.<any>
send transfer request to witness node
Kind: instance method of GXClient
Param | Type | Default | Description |
---|---|---|---|
to | String | to account name | |
memo | String | function | memo | |
amount_asset | String | e.g: '1 GXC' | |
broadcast | Boolean | false | |
options | Object | ||
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.getStakingPrograms()
get staking programs
Kind: instance method of GXClient
# gxClient.createStaking(to, amount, program_id, options) ⇒ Promise.<any>
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
to | String | trust node account name |
amount | Number | the amount of GXC to staking |
program_id | String | the staking program id |
options | Object | |
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.updateStaking(to, staking_id, options) ⇒ Promise.<any>
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
to | String | trust node account name |
staking_id | String | the staking id |
options | Object | |
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.claimStaking(to, staking_id, options) ⇒ Promise.<any>
Kind: instance method of GXClient
Param | Type | Description |
---|---|---|
to | String | trust node account name |
staking_id | String | the staking id |
options | Object | |
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.getContractABI(contract_name) ⇒ Promise.<any>
get contract abi by contract_name
Kind: instance method of GXClient
Param | Type |
---|---|
contract_name | String |
# gxClient.getContractTable(contract_name) ⇒ Promise.<any>
get contract table by contract_name
Kind: instance method of GXClient
Param | Type |
---|---|
contract_name | String |
# gxClient.getTableObjects(contract_name, table_name, start, limit) ⇒ Promise.<any>
fetch contract table record by contract_name and table_name
Kind: instance method of GXClient
Param | Type | Default |
---|---|---|
contract_name | String | |
table_name | String | |
start | Number | 0 |
limit | Number | 100 |
# gxClient.getTableObjectsEX(contract_name, table_name, lower_bound, upper_bound, limit, reverse) ⇒ *
fetch contract table record by contract_name and table_name
Kind: instance method of GXClient
Param | Default |
---|---|
contract_name | |
table_name | |
lower_bound | 0 |
upper_bound | |
limit | 100 |
reverse | false |
# gxClient.createContract(contract_name, code, abi, vm_type, vm_version, broadcast, options) ⇒ Promise.<any>
deploy smart contract
Kind: instance method of GXClient
Param | Type | Default | Description |
---|---|---|---|
contract_name | String | ||
code | String | bytecode | |
abi | Object | abi object | |
vm_type | String | 0 | |
vm_version | String | 0 | |
broadcast | Boolean | false | |
options | Object | ||
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.updateContract(contract_name, newOwner, code, abi, broadcast, options) ⇒ Request
| PromiseLike.<T>
| Promise.<T>
update smart contract
Kind: instance method of GXClient
Param | Type | Default | Description |
---|---|---|---|
contract_name | String | ||
newOwner | String | new owner account name | |
code | String | same to createContract | |
abi | Object | same to createContract | |
broadcast | Boolean | false | |
options | Object | ||
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.callContract(contract_name, method_name, params, amount_asset, broadcast, options) ⇒ Promise.<any>
call smart contract method
Kind: instance method of GXClient
Param | Type | Default | Description |
---|---|---|---|
contract_name | String | The name of the smart contract | |
method_name | String | Method/Action name | |
params | JSON | parameters | |
amount_asset | String | same to transfer eg."100 GXC" | |
broadcast | Boolean | false | Broadcast the transaction or just return a serialized transaction |
options | Object | ||
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.vote(accounts, broadcast, options) ⇒ Promise.<any>
vote for accounts
Kind: instance method of GXClient
Params: options.append {bool} - default: true
Param | Type | Default | Description |
---|---|---|---|
accounts | Array.<String> | An array of account_names to vote | |
broadcast | Boolean | false | |
options | Object | ||
options.fee_symbol | String | e.g: 'GXC' |
# gxClient.fee(operation, feeAssetId) ⇒ Promise.<any>
calculate fee of a operation
Kind: instance method of GXClient
Param | Type | Default |
---|---|---|
operation | Object | |
feeAssetId | String | 1.3.1 |
# gxClient.broadcast(tx) ⇒ Promise.<any>
broadcast transaction
Kind: instance method of GXClient
Param | Type |
---|---|
tx | TransactionBuilder |
# signatureProvider : function
This callback is displayed as a global member.
Kind: global typedef
Param | Type | Description |
---|---|---|
transaction | TransactionBuilder | |
chain_id | String | Chain Id |