# Contract

Smart contract operations and state queries

## Validate WASM contract

> Validate a WASM contract bytecode before deployment

```json
{"openapi":"3.0.3","info":{"title":"Amadeus Blockchain API","version":"1.5.0"},"tags":[{"name":"Contract","description":"Smart contract operations and state queries"}],"servers":[{"url":"https://nodes.amadeus.bot","description":"Mainnet"},{"url":"https://testnet-rpc.ama.one","description":"Testnet"}],"paths":{"/api/contract/validate":{"post":{"tags":["Contract"],"summary":"Validate WASM contract","description":"Validate a WASM contract bytecode before deployment","requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","description":"WASM bytecode"}}}},"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"valid":{"type":"boolean"}}}}}}}}}}}
```

## Get contract state by key

> Retrieve a value from contract state storage

```json
{"openapi":"3.0.3","info":{"title":"Amadeus Blockchain API","version":"1.5.0"},"tags":[{"name":"Contract","description":"Smart contract operations and state queries"}],"servers":[{"url":"https://nodes.amadeus.bot","description":"Mainnet"},{"url":"https://testnet-rpc.ama.one","description":"Testnet"}],"paths":{"/api/contract/get":{"post":{"tags":["Contract"],"summary":"Get contract state by key","description":"Retrieve a value from contract state storage","requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","description":"Storage key (raw bytes)"}}}},"responses":{"200":{"description":"Contract state value","content":{"application/json":{"schema":{"type":"object"}}}}}}}}}
```

## Get contract state by prefix

> Retrieve all key-value pairs from contract state with a given prefix

```json
{"openapi":"3.0.3","info":{"title":"Amadeus Blockchain API","version":"1.5.0"},"tags":[{"name":"Contract","description":"Smart contract operations and state queries"}],"servers":[{"url":"https://nodes.amadeus.bot","description":"Mainnet"},{"url":"https://testnet-rpc.ama.one","description":"Testnet"}],"paths":{"/api/contract/get_prefix":{"post":{"tags":["Contract"],"summary":"Get contract state by prefix","description":"Retrieve all key-value pairs from contract state with a given prefix","requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","description":"Storage key prefix (raw bytes)"}}}},"responses":{"200":{"description":"Contract state entries (vecpak encoded)","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}}}}
```

## Execute contract view function (GET)

> Execute a read-only contract function with no arguments

```json
{"openapi":"3.0.3","info":{"title":"Amadeus Blockchain API","version":"1.5.0"},"tags":[{"name":"Contract","description":"Smart contract operations and state queries"}],"servers":[{"url":"https://nodes.amadeus.bot","description":"Mainnet"},{"url":"https://testnet-rpc.ama.one","description":"Testnet"}],"paths":{"/api/contract/view":{"get":{"tags":["Contract"],"summary":"Execute contract view function (GET)","description":"Execute a read-only contract function with no arguments","parameters":[{"name":"contract","in":"path","required":true,"description":"Contract address (Base58 encoded)","schema":{"type":"string"}},{"name":"function","in":"path","required":true,"description":"Function name","schema":{"type":"string"}},{"name":"pk","in":"query","required":false,"description":"Caller public key (Base58 encoded)","schema":{"type":"string"}}],"responses":{"200":{"description":"Function execution result","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"result":{"type":"string"},"logs":{"type":"array","items":{"type":"string"}}}}}}}}}}}}
```

## Execute contract view function (vecpak)

> Execute a read-only contract function using vecpak encoding

```json
{"openapi":"3.0.3","info":{"title":"Amadeus Blockchain API","version":"1.5.0"},"tags":[{"name":"Contract","description":"Smart contract operations and state queries"}],"servers":[{"url":"https://nodes.amadeus.bot","description":"Mainnet"},{"url":"https://testnet-rpc.ama.one","description":"Testnet"}],"paths":{"/api/contract/view":{"post":{"tags":["Contract"],"summary":"Execute contract view function (vecpak)","description":"Execute a read-only contract function using vecpak encoding","requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","description":"Vecpak encoded map with fields:\n- contract: Contract address (48 bytes)\n- function: Function name (string)\n- args: Function arguments (array)\n- pk: Optional caller public key (48 bytes)\n"}}}},"responses":{"200":{"description":"Function execution result","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"result":{"type":"string","description":"Execution result (ASCII dump)"},"logs":{"type":"array","items":{"type":"string"},"description":"Execution logs"}}}}}}}}}}}
```

## Get richlist

> Retrieve the list of top AMA token holders

```json
{"openapi":"3.0.3","info":{"title":"Amadeus Blockchain API","version":"1.5.0"},"tags":[{"name":"Contract","description":"Smart contract operations and state queries"}],"servers":[{"url":"https://nodes.amadeus.bot","description":"Mainnet"},{"url":"https://testnet-rpc.ama.one","description":"Testnet"}],"paths":{"/api/contract/richlist":{"get":{"tags":["Contract"],"summary":"Get richlist","description":"Retrieve the list of top AMA token holders","responses":{"200":{"description":"Richlist","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"richlist":{"type":"array","items":{"type":"object","properties":{"address":{"type":"string"},"balance":{"type":"string"}}}}}}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ama.one/http-api/contract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
