query
Allows you to submit scripts to query the blockchain.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl"_10_10fcl.query(opts)
Or import directly the specific function:
_10import { query } from "@onflow/fcl"_10_10query(opts)
Usage
_16import * as fcl from '@onflow/fcl';_16_16const result = await fcl.query({_16  cadence: `_16    access(all) fun main(a: Int, b: Int, addr: Address): Int {_16      log(addr)_16      return a + b_16    }_16  `,_16  args: (arg, t) => [_16    arg(7, t.Int), // a: Int_16    arg(6, t.Int), // b: Int_16    arg('0xba1132bc08f82fe2', t.Address), // addr: Address_16  ],_16});_16console.log(result); // 13
Parameters
opts (optional)
- Type:
 
_10export interface QueryOptions {_10  cadence?: string_10  args?: ArgsFn_10  template?: any_10  isSealed?: boolean_10  limit?: number_10}
- Description: Query options configuration
 
Properties:
cadence- A valid cadence script (required)args- Any arguments to the script if needed should be supplied via a function that returns an array of argumentslimit- Compute (Gas) limit for query.template- Interaction Template for a scriptisSealed- Block Finality
Returns
Promise<any>
A JSON representation of the response