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-react-native"_10_10fcl.query(opts)
Or import directly the specific function:
_10import { query } from "@onflow/fcl-react-native"_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
Returns
Promise<any>
A JSON representation of the response