SmartContract.call() method
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Call any function on this contract
Example
// read functions will return the data from the contract
const myValue = await contract.call("myReadFunction");
console.log(myValue);
// write functions will return the transaction receipt
const tx = await contract.call("myWriteFunction", arg1, arg2);
const receipt = tx.receipt;
// Optionally override transaction options
await contract.call("myWriteFunction", arg1, arg2, {
gasLimit: 1000000, // override default gas limit
value: ethers.utils.parseEther("0.1"), // send 0.1 ether with the contract call
};
Signature:
call(functionName: string, ...args: unknown[] | [...unknown[], CallOverrides]): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
functionName | string | the name of the function to call |
args | unknown[] | [...unknown[], CallOverrides] | the arguments of the function |
Returns:
Promise<any>