Skip to main content

JSON-RPC Specs

The EIP-1193 style JSON-RPC API for Hive wallet providers outlined in this page are implemented in Aioha. These are designed to be platform and transport agnostic.

Any RPC methods not defined here shall be redirected to a Hive API node.

Aioha RPC Errors

For every RPC method, the error returned (if any) shall follow the convention below:

{
"message": "human readable error message",
"code": 4001
}

The error code returned are as follows, for Aioha-specific errors:

info

The application may use the error codes to provide a localized message to be displayed to the user.

Error CodeNameDescription
4001User Rejected RequestThe user rejected the request.
4002Request ExpiredThe request has expired.
4100UnauthorizedThe requested method and/or account has not been authorized by the user.
4200Unsupported MethodThe requested method is not supported.
4201Unsupported ProviderThe requested provider is not supported or registered.
4900DisconnectedThe provider is disconnected.
4901Already connectedAccount connection has already been established with the provider.
5000Unknown ErrorUnknown error occurred while serving the request.
5001Extension Not FoundThe required browser extension is not installed.
5002Missing UsernameUsername is required.
5003Missing/Invalid OptionsValid options are required.
5004Invalid MemoMemo must start with a #.
5005Unsupported Key TypeChosen key type is not supported for the requested operation.
5200Nothing To DoThere are no actions required to complete the request.
5201Invalid Account AuthCould not add/remove itself to/from account auth.
5900Connection ErrorFailed to establish connection to the device.
5901Unassociated UserUsername is not associated with the device.
5902Discovery ErrorFailed to search accounts associated with the device.
5903Signature Request ErrorFailed to obtain message/transaction signature from the device.
5904Hash signing disabledHash signing is not enabled on the device.

Aioha RPC Methods

Login

info

You may need to subscribe to hiveauth_login_request event in order to receive the HiveAuth QR code payload.

{
"method": "aioha_api.login",
"params": {
"provider": "keychain",
"username": "aioha",
"message": "Hello World",
"key_type": "posting",
"login_title": "Login"
}
}

Login and Decrypt Memo

{
"method": "aioha_api.login_memo",
"params": {
"provider": "keychain",
"username": "aioha",
"message": "#9RdpW9b7nfmdzipLJSZVQpcnpR3ipygGZg9DyxQZgBkbztb3NXBhSVKZJRLMs42KdcwUfHTkCWHpiGxTzR3jFfuaoY274chw3DyR16R2Esn5dMtw2Sa2Eh2W8EDochfiBKFmxAGauZRZChWz9Z5AmkS",
"key_type": "posting"
}
}

Logout

{
"method": "aioha_api.logout",
"params": {}
}

Decrypt Memo

{
"method": "aioha_api.decrypt_memo",
"params": {
"message": "#9RdpW9b7nfmdzipLJSZVQpcnpR3ipygGZg9DyxQZgBkbztb3NXBhSVKZJRLMs42KdcwUfHTkCWHpiGxTzR3jFfuaoY274chw3DyR16R2Esn5dMtw2Sa2Eh2W8EDochfiBKFmxAGauZRZChWz9Z5AmkS",
"key_type": "posting"
}
}

Sign Message

{
"method": "aioha_api.sign_message",
"params": {
"message": "Hello World",
"key_type": "posting"
}
}

Sign Transaction

{
"method": "aioha_api.sign_tx",
"params": {
"tx": {
"ref_block_num": 27912,
"ref_block_prefix": 1175138206,
"expiration": "2024-06-07T10:23:57",
"operations": [
[
"transfer",
{
"from": "randomvlogs",
"to": "randomvlogs",
"amount": "0.001 HIVE",
"memo": "Aioha Test"
}
]
],
"extensions": []
},
"key_type": "posting"
}
}

Sign and Broadcast Transaction

{
"method": "aioha_api.sign_and_broadcast_tx",
"params": {
"ops": [
["vote", {
"author": "sagarkothari88",
"permlink": "2024-06-05-daily-updates-from-sagarkothari88",
"voter": "techcoderx",
"weight": 10000
}]
],
"key_type": "posting"
}
}

Get Registered Providers

{
"method": "aioha_api.get_registered_providers",
"params": {}
}

Get Current Provider

{
"method": "aioha_api.get_current_provider",
"params": {}
}

Get Current User

{
"method": "aioha_api.get_current_user",
"params": {}
}

Is Logged In

{
"method": "aioha_api.is_logged_in",
"params": {}
}

Is Provider Registered

{
"method": "aioha_api.is_provider_registered",
"params": {
"enabled": true
}
}

Operations

The return value for these method calls will be equivalent to sign and broadcast transaction result above.

Social

{
"method": "aioha_api.vote",
"params": {
"author": "alice",
"permlink": "my-permlink",
"weight": 10000
}
}

Custom JSON

{
"method": "aioha_api.custom_json",
"params": {
"key_type": "posting"
"id": "my-id",
"json": {
"foo": "bar"
},
"title": "Display Title"
}
}

Claim Rewards

{
"method": "aioha_api.claim_rewards",
"params": {}
}

Transfer

Transfer HIVE/HBD to another account.

{
"method": "aioha_api.transfer",
"params": {
"to": "bob",
"amount": 1,
"asset": "HIVE",
"memo": "Transferred using Aioha with memo"
}
}

HIVE staking

note

to is an optional parameter when staking HIVE to another account.

{
"method": "aioha_api.stake_hive",
"params": {
"to": "itself",
"amount": 1000
}
}

Governance

{
"method": "aioha_api.vote_witness",
"params": {
"witness": "thewitness",
"approve": true
}
}

Authority

note

Set weight to 0 to remove the account auth.

{
"method": "aioha_api.add_account_auth",
"params": {
"account": "aioha",
"authority": "posting",
"weight": 1
}
}

Call VSC Contract

Call a VSC contract from L1.

{
"method": "aioha_api.vsc_call_contract",
"params": {
"contract_id": "vs41q9c3yg82k4q76nprqk89xzk2n8zhvedrz5prnrrqpy6v9css3seg2q43uvjdc500",
"action": "dumpEnv",
"payload": "tx payload",
"authority": "active"
}
}

Events

Connected

The connect event is emitted every time an account has been successfully authenticated, resulting in a transition from a disconnected state to a connected state.

aioha.on('connect', () => void)

Disconnected

The disconnect event is emitted every time an account was logged out and no accounts remain authenticated.

aioha.on('disconnect', () => void)

Account Changed

The account_changed event is emitted every time the current logged in account changes, under the following circumstances:

  1. Another account has been added on top of the existing connected account
  2. The connected account has been changed from one previously authenticated account to another
  3. An account has been disconnected while leaving other accounts remain connected.
aioha.on('account_changed', () => void)

HiveAuth Login Request

The hiveauth_login_request event is emitted every time a new HiveAuth login request is created. This event contains the payload needed to display a QR code to be scanned using a HiveAuth compatible PKSA.

aioha.on('hiveauth_login_request', (payload: string) => void)