WAX Smart Contract icon

WAX Smart Contract

Execute actions on WAX smart contracts

Overview

This node interacts with WAX blockchain smart contracts, specifically allowing users to read data from smart contract tables. The "Get Table Data" operation queries a specified table within a smart contract, returning rows of data based on provided query parameters such as scope, bounds, and limits.

Common scenarios include:

  • Retrieving token balances or asset information stored in a smart contract.
  • Accessing user-specific or global data maintained by decentralized applications on the WAX blockchain.
  • Fetching paginated or filtered data from large tables for further processing or display.

For example, a user might query the accounts table of the eosio.token contract scoped to their account name to get their token balances.

Properties

Name Meaning
Contract Name Name of the smart contract to query (e.g., eosio.token, atomicassets).
Table Name Name of the table within the contract to retrieve data from.
Scope Scope of the table, usually an account name or contract name that defines the subset of data to query.
Lower Bound Optional lower bound for the query. For key type name, use account names; for numeric keys like i64, use numbers. Defines the starting point of the query range.
Upper Bound Optional upper bound for the query. Same format rules as Lower Bound. Defines the end point of the query range.
Limit Maximum number of results to return. Must be at least 1. Defaults to 50.
Key Type Type of the primary key used for indexing the table. Options include: float128, float64, i128, i256, i64, name, ripemd160, sha256. Default is i64.
Auto Convert Account Names When key type is i64, this boolean option enables automatic conversion of account names in bounds to their corresponding i64 representation. Defaults to true.
Index Position Position of the index to query: 1 for primary index, 2 or higher for secondary indexes. Defaults to 1.
API Endpoint URL of the WAX blockchain API endpoint to send the query to. Defaults to https://wax.greymass.com.

Output

The output JSON contains the following fields:

  • success: Boolean indicating if the query was successful.
  • operation: The operation performed, here always "getTable".
  • contract: The smart contract name queried.
  • table: The table name queried.
  • scope: The scope used for the query.
  • queryParams: The full set of parameters sent to the blockchain API, including code, scope, table, limit, index position, key type, and bounds.
  • originalBounds: The original lower and upper bounds as input by the user.
  • convertedBounds: The possibly converted bounds after applying automatic account name to i64 conversion.
  • autoConvert: Whether automatic conversion was enabled.
  • rows: An array of rows returned from the table query.
  • more: Boolean indicating if there are more rows available beyond the current result set.
  • next_key: A key to use for fetching the next page of results if more is true.

No binary data is output by this operation.

Dependencies

  • Requires access to a WAX blockchain API endpoint (default: https://wax.greymass.com).
  • Uses the eosjs library to interact with the blockchain.
  • No special credentials are required for reading table data.
  • The node depends on network connectivity to the specified API endpoint.

Troubleshooting

  • Invalid character in name error: If the scope or bounds contain invalid characters (not in .12345abcdefghijklmnopqrstuvwxyz), the node will throw an error. Ensure all account names or contract names are valid WAX names.
  • Failed to convert bounds to i64: When using i64 key type with auto-conversion enabled, non-numeric bounds must be valid WAX account names. Invalid names will cause conversion failure.
  • API endpoint unreachable or timeout: Network issues or incorrect API endpoint URLs will cause request failures. Verify the endpoint URL and network connectivity.
  • Empty or no rows returned: This may indicate the table or scope does not exist or has no data matching the query parameters.
  • Limit too high: Setting very high limits may cause slow responses or timeouts. Use reasonable limits and paginate using next_key if needed.

Links and References

Discussion