Skip to content

Commit

Permalink
Merge pull request #1233 from ainblockchain/bugfix/platfowner/bugfix
Browse files Browse the repository at this point in the history
Add or update account APIs of JSON_RPC_API.md file
  • Loading branch information
platfowner committed Feb 2, 2024
2 parents e4101eb + 37fbe9a commit e04c5be
Showing 1 changed file with 96 additions and 40 deletions.
136 changes: 96 additions & 40 deletions JSON_RPC_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
- [ain_getStateInfo](#ain_getstateinfo)
- [ain_getStateUsage](#ain_getstateusage)
- [Account API](#account-api)
- [ain_getAddress](#ain_getaddress)
- [ain_getBalance](#ain_getbalance)
- [ain_getConsensusStakeAmount](#ain_getconsensusstakeamount)
- [ain_getNonce](#ain_getnonce)
- [ain_isValidator](#ain_isvalidator)
- [ain_getTimestamp](#ain_gettimestamp)
- [ain_getValidatorInfo](#ain_getvalidatorinfo)
- [Transaction API](#transaction-api)
- [ain_getPendingTransactions](#ain_getpendingtransactions)
- [ain_getTransactionByBlockNumberAndIndex](#ain_gettransactionbyblocknumberandindex)
Expand Down Expand Up @@ -1084,15 +1085,51 @@ Response

## Account API

### ain_getAddress

Returns the address of the blockchain node's account.

**Parameters**

**Returns**

`String` - The address.

**Example**

Request
```
curl https://testnet-api.ainetwork.ai/json-rpc -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ain_getAddress",
"params": {
"protoVer": "1.1.3"
}
}'
```

Response
```
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"result": "0x000AF024FEDb636294867bEff390bCE6ef9C5fc4",
"protoVer": "1.1.3"
}
}
```

### ain_getBalance

Returns the balance of an account.
Returns the balance of the given account.

**Parameters**

An object with a property:

- address: `String` - address of the account to get the balance of.
- address: `String` - address of the account.

**Returns**

Expand All @@ -1107,33 +1144,37 @@ curl https://testnet-api.ainetwork.ai/json-rpc -X POST -H "Content-Type: applica
"id": 1,
"method": "ain_getBalance",
"params": {
"address": "0xc94770007dda54cF92009BFF0dE90c06F603a09f"
"protoVer": "1.1.3",
"address": "0xAAAAeEDFf1d2cD909465182165ccc267549554Fc"
}
}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":98347
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"result": 578990573.3755,
"protoVer": "1.1.3"
}
}
```

### ain_getConsensusStakeAmount
### ain_getNonce

Returns the amount of AIN the account (node) is staking for participating in the consensus protocol.
Returns the nonce, number of transactions an address has sent, of the given account

**Parameters**[](#parameters-1)
**Parameters**

An object with a property:

- address: `String` - address of the account.
- address: `String` - address of the account

**Returns**

`Number` - The amount at stake.
`Number` - The nonce.

**Example**

Expand All @@ -1142,35 +1183,39 @@ Request
curl https://testnet-api.ainetwork.ai/json-rpc -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ain_getConsensusStakeAmount",
"method": "ain_getNonce",
"params": {
"address": "0xc94770007dda54cF92009BFF0dE90c06F603a09f"
"protoVer": "1.1.3",
"address": "0xAAAAeEDFf1d2cD909465182165ccc267549554Fc"
}
}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":1000
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"result": 91,
"protoVer": "1.1.3"
}
}
```

### ain_getNonce
### ain_getTimestamp

Returns the nonce (= number of transactions an address has sent) of an address.
Returns the timestamp of the given account

**Parameters**

An object with a property:

- address: `String` - address of the account to get the transaction count of
- address: `String` - address of the account

**Returns**

`Number` - The nonce.
`Number` - The timestamp.

**Example**

Expand All @@ -1179,35 +1224,39 @@ Request
curl https://testnet-api.ainetwork.ai/json-rpc -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ain_getNonce",
"method": "ain_getTimestamp",
"params": {
"address": "0xc94770007dda54cF92009BFF0dE90c06F603a09f"
"protoVer": "1.1.3",
"address": "0xAAAAeEDFf1d2cD909465182165ccc267549554Fc"
}
}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":10
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"result": 0,
"protoVer": "1.1.3"
}
}
```

### ain_isValidator
### ain_getValidatorInfo

Returns whether the node is currently a validator or not.
Returns the information of the given block validator

**Parameters**

An object with a property:

- address: `String` - address of the account to check if it's currently in the validator set
- address: `String` - address of the block validator's account

**Returns**

`Boolean` - Whether the node is a validator or not.
`Object` - The validator's information.

**Example**

Expand All @@ -1216,19 +1265,26 @@ Request
curl https://testnet-api.ainetwork.ai/json-rpc -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ain_isValidator",
"method": "ain_getValidatorInfo",
"params": {
"address": "0xc94770007dda54cF92009BFF0dE90c06F603a09f"
"protoVer": "1.1.3",
"address": "0x000AF024FEDb636294867bEff390bCE6ef9C5fc4"
}
}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":true
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"result": {
"isWhitelisted": true,
"stake": 0
},
"protoVer": "1.1.3"
}
}
```

Expand Down

0 comments on commit e04c5be

Please sign in to comment.