useContractStaticCall
Returns a function to static call a function on a contract.
Usage
import {useContract, useContractStaticCall} from '@incirlabs/react-ethooks';
export default function MyComponent() {
const MyContract = useContract('0x00', MyContractABI);
const staticTransfer = useContractStaticCall(MyContract, 'transfer');
const onSomeAction = async () => {
const result = await staticTransfer(['0x123', 1234, {from: '0x456'}]);
if (result.status) {
console.log(`Result: ${result.data}`);
} else {
console.log(`Error: ${result.error.message}`);
}
};
}
Parameters
contract
Contract instance returned from useContract
or ethers.Contract
Type | Default |
---|---|
ethers.Contract | Required |
method
Function name to call on the contract instance.
Type | Default |
---|---|
string | Required |
defaultArgs
Default arguments to pass to the function.
Type | Default |
---|---|
(string | number)[] | undefined |
Returns
Function to execute the static call on the contract instance.
Type |
---|
(args: (string | number)[]) => Promise<ContractResult> |