Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Add query APIs for KIP149
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonLewis committed Feb 7, 2024
1 parent 798e6e5 commit f5d2443
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions KIPs/kip-149.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,81 @@ func ReadActiveAddressFromRegistry(backend bind.ContractCaller, name string, num
}
```

#### JSON-RPC APIs

The following JSON-RPC methods for the Klaytn node should be added to provide the records of registered system contracts.

1. `klay_getActiveAddressFromRegistry`

- Parameters:
- `name`: the name of the system contract in string.
- `number`: (optional) integer or hexadecimal block number, or the string "pending" or "latest".
- Description: Returns the active address of the system contract registered as `name` if exists.
- Returns:
- `address`: The address of the active system contract.
- Example
```json
// Request
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getActiveAddressFromRegistry", "params":["KIP113", "latest"],"id":1}' http://localhost:8551
// Response
{
"jsonrpc":"2.0",
"id":1,
"result": "0x0000000000000000000000000000000000000402"
}

// Request - no active system contract
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getActiveAddressFromRegistry", "params":["KIP114", "latest"],"id":1}' http://localhost:8551
// Response
{
"jsonrpc":"2.0",
"id":1,
"error":{
"code":-32000,
"message":"no active address for KIP114"
}
}
```
2. `klay_getAllRecordsFromRegistry`

- Parameters:
- `name`: the name of the system contract in string.
- `number`: (optional) integer or hexadecimal block number, or the string "pending" or "latest".
- Description: Returns all records of the system contract registered as `name` if it has been registered.
- Returns:
- `Record[]`: An array of the records of the system contract.
- `Record`: A struct of the record with the following fields.
- `Addr`: The address of the system contract.
- `Activation`: The block number when the system contract will be activated.
- Example
```json
// Request
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getAllRecordsFromRegistry", "params":["KIP113", "latest"],"id":1}' http://localhost:8551
// Response
{
"jsonrpc":"2.0",
"id":1,
"result":[
{
"Addr":"0x0000000000000000000000000000000000000402",
"Activation":0
}
]
}

// request - no records
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getAllRecordsFromRegistry", "params":["KIP114", "latest"],"id":1}' http://localhost:8551
// Response
{
"jsonrpc":"2.0",
"id":1,
"error":{
"code":-32000,
"message":"KIP114 has not been registered"
}
}
```

## Rationale

### Bytecode Injection for Registry Deployment
Expand Down

0 comments on commit f5d2443

Please sign in to comment.