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:
The application may use the error codes to provide a localized message to be displayed to the user.
Error Code | Name | Description |
---|---|---|
4001 | User Rejected Request | The user rejected the request. |
4002 | Request Expired | The request has expired. |
4100 | Unauthorized | The requested method and/or account has not been authorized by the user. |
4200 | Unsupported Method | The requested method is not supported. |
4201 | Unsupported Provider | The requested provider is not supported or registered. |
4900 | Disconnected | The provider is disconnected. |
4901 | Already connected | Account connection has already been established with the provider. |
5000 | Unknown Error | Unknown error occurred while serving the request. |
5001 | Extension Not Found | The required browser extension is not installed. |
5002 | Missing Username | Username is required. |
5003 | Missing/Invalid Options | Valid options are required. |
5004 | Invalid Memo | Memo must start with a #. |
5005 | Unsupported Key Type | Chosen key type is not supported for the requested operation. |
5200 | Nothing To Do | There are no actions required to complete the request. |
5201 | Invalid Account Auth | Could not add/remove itself to/from account auth. |
5900 | Connection Error | Failed to establish connection to the device. |
5901 | Unassociated User | Username is not associated with the device. |
5902 | Discovery Error | Failed to search accounts associated with the device. |
5903 | Signature Request Error | Failed to obtain message/transaction signature from the device. |
5904 | Hash signing disabled | Hash signing is not enabled on the device. |
Aioha RPC Methods
Login
- Request
- Result
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"
}
}
{
"provider": "keychain",
"result": "2020647841097bca7d9e84c39df209ac2df9b42c5b194ee2a690304ce8c140690f5296566b5da0ae9d9950243871bf17fa26b34b671dc8284bf7fba767958a5508",
"username": "aioha",
"public_key": "STM5jruaymFQ93jwUp15r9SF5wPeaNvRKFE4nbbJv4vfHCk5a6zRu"
}
Login and Decrypt Memo
- Request
- Result
{
"method": "aioha_api.login_memo",
"params": {
"provider": "keychain",
"username": "aioha",
"message": "#9RdpW9b7nfmdzipLJSZVQpcnpR3ipygGZg9DyxQZgBkbztb3NXBhSVKZJRLMs42KdcwUfHTkCWHpiGxTzR3jFfuaoY274chw3DyR16R2Esn5dMtw2Sa2Eh2W8EDochfiBKFmxAGauZRZChWz9Z5AmkS",
"key_type": "posting"
}
}
{
"provider": "keychain",
"result": "#Hello World",
"username": "aioha"
}
Logout
- Request
- Result
{
"method": "aioha_api.logout",
"params": {}
}
This method does not return anything.
Decrypt Memo
- Request
- Result
{
"method": "aioha_api.decrypt_memo",
"params": {
"message": "#9RdpW9b7nfmdzipLJSZVQpcnpR3ipygGZg9DyxQZgBkbztb3NXBhSVKZJRLMs42KdcwUfHTkCWHpiGxTzR3jFfuaoY274chw3DyR16R2Esn5dMtw2Sa2Eh2W8EDochfiBKFmxAGauZRZChWz9Z5AmkS",
"key_type": "posting"
}
}
#Hello World
Sign Message
- Request
- Result
{
"method": "aioha_api.sign_message",
"params": {
"message": "Hello World",
"key_type": "posting"
}
}
{
"signature": "2020647841097bca7d9e84c39df209ac2df9b42c5b194ee2a690304ce8c140690f5296566b5da0ae9d9950243871bf17fa26b34b671dc8284bf7fba767958a5508",
"public_key": "STM5jruaymFQ93jwUp15r9SF5wPeaNvRKFE4nbbJv4vfHCk5a6zRu"
}
Sign Transaction
- Request
- Result
{
"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"
}
}
{
"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": [],
"signatures": [
"20469faba4c128ef41c4e444ef5422e88ed9397d43a7c9713a8e59c170de45eea539b63ced8f4ff048442bdcca3b96848f6f740e655c971f9cae00b54535c8eea0"
]
}
Sign and Broadcast Transaction
- Request
- Result
{
"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"
}
}
87c10767531071732fe15e6c34cf275900c342a3
Get Registered Providers
- Request
- Result
{
"method": "aioha_api.get_registered_providers",
"params": {}
}
["keychain", "peakvault", "ledger", "hiveauth", "hivesigner"]
Get Current Provider
- Request
- Result
{
"method": "aioha_api.get_current_provider",
"params": {}
}
hiveauth
Get Current User
- Request
- Result
{
"method": "aioha_api.get_current_user",
"params": {}
}
aioha
Is Logged In
- Request
- Result
{
"method": "aioha_api.is_logged_in",
"params": {}
}
true
Is Provider Registered
- Request
- Result
{
"method": "aioha_api.is_provider_registered",
"params": {
"enabled": true
}
}
true
Operations
The return value for these method calls will be equivalent to sign and broadcast transaction result above.
Social
- Vote
- Vote Many
- Comment
- Delete Comment
- Reblog
- Follow
- Ignore
{
"method": "aioha_api.vote",
"params": {
"author": "alice",
"permlink": "my-permlink",
"weight": 10000
}
}
{
"method": "aioha_api.vote_many",
"params": [
{
"author": "author1",
"permlink": "permlink1",
"weight": 10000
},
{
"author": "author2",
"permlink": "permlink2",
"weight": 5000
}
]
}
options
is an optional comment_options
config.
{
"method": "aioha_api.comment",
"params": {
"parent_author": "pa",
"parent_permlink": "pp",
"permlink": "my-permlink",
"title": "Post Title",
"body": "An awesome post body goes here",
"json_metadata": {
"foo": "bar"
},
"options": {
"author": "aioha",
"permlink": "my-permlink",
"max_accepted_payout": "1000000.000 HBD",
"percent_hbd": 10000,
"allow_votes": true,
"allow_curation_rewards": true,
"extensions": [[0, {
"beneficiaries": [
{
"account": "alice",
"weight": 100
}, {
"account": "bob",
"weight": 150
}
]
}]]
}
}
}
The post or comment must contain no child comments or positive rshares.
{
"method": "aioha_api.delete_comment",
"params": {
"permlink": "permlink-to-delete",
}
}
{
"method": "aioha_api.reblog",
"params": {
"author": "charlie",
"permlink": "charlie-awesome-permlink",
"reblog": true
}
}
{
"method": "aioha_api.follow",
"params": {
"author": "bob",
"follow": true
}
}
{
"method": "aioha_api.ignore",
"params": {
"author": "spam.account"
}
}
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.
- One Time
- Recurrent
{
"method": "aioha_api.transfer",
"params": {
"to": "bob",
"amount": 1,
"asset": "HIVE",
"memo": "Transferred using Aioha with memo"
}
}
Set amount to 0 to cancel a recurrent transter.
{
"method": "aioha_api.transfer",
"params": {
"to": "bob",
"amount": 1,
"asset": "HIVE",
"memo": "Transferred using Aioha with memo",
"recurrent": {
"recurrence": 24,
"executions": 7
}
}
}
HIVE staking
- Stake
- Unstake
- Unstake (VESTS)
- Delegate
- Delegate (VESTS)
to
is an optional parameter when staking HIVE to another account.
{
"method": "aioha_api.stake_hive",
"params": {
"to": "itself",
"amount": 1000
}
}
Set amount to 0 to cancel unstake.
{
"method": "aioha_api.unstake_hive",
"params": {
"amount": 1000
}
}
Set amount to 0 to cancel unstake.
{
"method": "aioha_api.unstake_vests",
"params": {
"amount": 1000000
}
}
Set amount to 0 to undelegate.
{
"method": "aioha_api.delegate_staked_hive",
"params": {
"to": "charlie",
"amount": 1000
}
}
Set amount to 0 to undelegate.
{
"method": "aioha_api.delegate_vests",
"params": {
"to": "charlie",
"amount": 1000000
}
}
Governance
- Vote Witness
- Vote Proposals
- Set Proxy
{
"method": "aioha_api.vote_witness",
"params": {
"witness": "thewitness",
"approve": true
}
}
{
"method": "aioha_api.vote_proposals",
"params": {
"proposals": [0],
"approve": true
}
}
Set proxy to an empty string to clear proxy.
{
"method": "aioha_api.set_proxy",
"params": {
"proxy": "proxiedacc"
}
}
Authority
- Account Auths
- Key Auths
Set weight to 0 to remove the account auth.
{
"method": "aioha_api.add_account_auth",
"params": {
"account": "aioha",
"authority": "posting",
"weight": 1
}
}
Set weight to 0 to remove the key auth.
{
"method": "aioha_api.add_key_auth",
"params": {
"key": "STMxxxx",
"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:
- Another account has been added on top of the existing connected account
- The connected account has been changed from one previously authenticated account to another
- 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)