Skip to content

Latest commit

 

History

History
166 lines (149 loc) · 3.82 KB

File metadata and controls

166 lines (149 loc) · 3.82 KB

view_state_paginated

The view_state_paginated method is a custom method that allows you to view the state of a contract in a paginated way.

How to use it

First request send without next_page_token to get the first page of the state. Then, if the response contains next_page_token, you can send the next request with the next_page_token to get the next page of the state.

Example:

Request:

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "view_state_paginated",
  "params": {
    "block_id": 112457314,
    "account_id": "social.near"
  }
}

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "values": [
      {
        "key": "some_key1",
        "value": "some_value2"
      },
      {
        "key": "some_key2",
        "value": "some_value2"
      },
      ...
    ],
    "block_height": 112457314,
    "block_hash": "3hALqxyuTEmMsCx7rAjqXw9Fu8TKYosbmhx6uTEXM2dh",
    "next_page_token": "some_long_next_page_token_string_cd0eddf8acdff8b7010000fffff00002"
  },
  "id": "dontcare"
}

Next page request:

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "view_state_paginated",
  "params": {
    "block_id": 112457314,
    "account_id": "social.near",
    "next_page_token": "some_long_next_page_token_string_cd0eddf8acdff8b7010000fffff00002"
  }
}

Next page response:

{
  "jsonrpc": "2.0",
  "result": {
    "values": [
      {
        "key": "some_key3",
        "value": "some_value3"
      },
      {
        "key": "some_key4",
        "value": "some_value4"
      },
      ...
    ],
    "block_height": 112457314,
    "block_hash": "3hALqxyuTEmMsCx7rAjqXw9Fu8TKYosbmhx6uTEXM2dh",
    "next_page_token": "another_some_long_next_page_token_string_aa0bc7f347342560101010051432cc1"
  },
  "id": "dontcare"
}

In the last page response next_page_token field will be null.

view_receipt_record

The view_receipt_record method is a custom method that allows you to view the record of the receipt by its ID.

How to use it

Example

Request:

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "view_receipt_record",
  "params": {
    "receipt_id": "6aB1XxfnhuQ83FWHb5xyqssGnaD5CUQgxHpbAVJFRrPe"
  }
}

Response:

{
  "id": "dontcare",
  "jsonrpc": "2.0",
  "result": {
    "block_height": 118875440,
    "parent_transaction_hash": "6iJgcM5iZrWuhG4ZpUyX6ivtMQUho2S1JRdBYdY7Y7vX",
    "receipt_id": "6aB1XxfnhuQ83FWHb5xyqssGnaD5CUQgxHpbAVJFRrPe",
    "shard_id": 0
  }
}

emulate_tx

The emulate_tx method is a custom method that allows you to estimate transaction costs and simulate its execution without actually sending it to the network. For now simulation supports only FunctionCall action, for other actions it will return only estimate fee.

How to use it

Example

Request:

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "emulate_tx",
  "params": {
    "signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=",
    "wait_until": "INCLUDED_FINAL"
  }
}

or

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "emulate_tx",
  "params": [ "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE="
  ]
}

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "block_height": 156743532,
        "gas_price": 100000000,
        "results": [
            {
                "Transfer": {
                    "fee": 115123062500
                }
            }
        ]
    },
    "id": "dontcare"
}