useCallSubscription
Usage
import { useCallSubscription } from 'useink'
import { pickDecoded } from 'useink/utils'
import metadata from 'contract/metadata.json'
const CONTRACT_ADDRESS = '...'
// We define a response type so that `get.result.value.decoded` is of type SuccessfulResponse
interface SuccessfulResponse {
foo: 'bar'
}
export const CallGetOnNewBlocks: React.FC = () => {
const contract = useContract(CONTRACT_ADDRESS, metadata, 'aleph')
const args = ['arg-1', 2]
const get = useCallSubscription<SuccessfulResponse>(contract, 'get', args)
return (
<>
<h2>Get the Result the hard way: {get.result?.ok ? get.result.value.decoded.foo : '--'}</h2>
<h2>Or the easy way: {pickDecoded(get.result)?.foo || '--'}</h2>
</>
)
}Calling with a default caller address
Return Value
Last updated