useContractWrite
Function: useContractWrite()
useContractWrite<
chainId,abi,functionName,args,config,selectData>(params):object
useContractWrite is a utility function designed to manage the process of interacting with a smart contract's writable or payable methods. It includes capabilities for simulating transactions, estimating gas, pre-approving transactions using guardians, and waiting for transaction receipts after execution. This function provides comprehensive functionality to handle the complexities of writing to smart contracts in a streamlined manner.
Variables, callbacks, and computed states are provided to empower developers with greater control during interaction with smart contracts. It integrates various modules like simulation, transaction pre-approval, and gas estimation into a unified interface.
Type Parameters
• chainId extends number
The chain ID where the contract resides.
• abi extends Abi | readonly unknown[]
The ABI of the contract, defining available methods.
• functionName extends string
The name of the writable or payable function of the contract.
• args extends unknown
The arguments required by the contract function.
• config extends Config = Config
Configuration options for the contract write, including chain details.
• selectData = SimulateContractData<abi, functionName, args, config, chainId>
Data derived from simulation output passed into this template.
Parameters
params
UseContractWriteParameters<chainId, abi, functionName, args, config, selectData>
Configuration parameters for the contract write operation.
Returns
object
A set of properties and methods to manage contract write operations
hash
hash:
undefined| `0x${string}`
isError
isError:
boolean
isLoading
isLoading:
boolean
isSimulateError
isSimulateError:
boolean
isSimulateLoading
isSimulateLoading:
boolean
isTxError
isTxError:
boolean
isTxLoading
isTxLoading:
boolean
isTxSuccess
isTxSuccess:
boolean
isWriteError
isWriteError:
boolean
isWriteSuccess
isWriteSuccess:
boolean
isWriting
isWriting:
boolean
readyToWrite
readyToWrite:
boolean
simulateData
simulateData:
undefined|SimulateContractReturnType<Abi,string, readonlyunknown[],Chain,Account,Chain> &object
simulateError
simulateError:
null|SimulateContractErrorType
txError
txError:
null|WaitForTransactionReceiptErrorType
txReceipt
txReceipt:
undefined| {blobGasPrice:bigint;blobGasUsed:bigint;blockHash: `0x${string}`;blockNumber:bigint;chainId:number;contractAddress:undefined|null| `0x${string}`;cumulativeGasUsed:bigint;effectiveGasPrice:bigint;from: `0x${string}`;gasUsed:bigint;logs:Log<bigint,number,false>[];logsBloom: `0x${string}`;root: `0x${string}`;status:"success"|"reverted";to:null| `0x${string}`;transactionHash: `0x${string}`;transactionIndex:number;type:TransactionType; }
Type declaration
undefined
{ blobGasPrice: bigint; blobGasUsed: bigint; blockHash: `0x${string}`; blockNumber: bigint; chainId: number; contractAddress: undefined | null | `0x${string}`; cumulativeGasUsed: bigint; effectiveGasPrice: bigint; from: `0x${string}`; gasUsed: bigint; logs: Log<bigint, number, false>[]; logsBloom: `0x${string}`; root: `0x${string}`; status: "success" | "reverted"; to: null | `0x${string}`; transactionHash: `0x${string}`; transactionIndex: number; type: TransactionType; }
writeContract()
writeContract: () =>
void
Returns
void
writeContractAsync()
writeContractAsync: () =>
Promise<void>
Returns
Promise<void>
writeError
writeError:
null|WriteContractErrorType
writeReset()
writeReset: () =>
void
Returns
void
Defined in
Last updated