OKTransaction
The OKTransaction represents a single step within a OKInteraction. It encapsulates all the details and state necessary to execute and monitor a transaction.
Instance: One per step in an interaction
Features:
- Manages user inputs data required for the transaction
- Manages the state of the transaction, including submission status and responses
- Manages state related to the contract's transactions (after submission)
- Captures logs and events emitted during transaction mining.
Methods
sendTX
sendTX submits the transaction on-chain returns block hash
<button
onClick={() => (chainOK ? current?.sendTX() : current?.switchChain())}
type="button"
disabled={
!current || !canSendTX || isSending || receipt !== undefined
}
>
{chain && !chainOK
? `Switch to ${chain?.name}`
: isSending
? "Please wait..."
: buttonLabel}
</button>
setValue
setValue sets the $value cell containing the transaction value v any float or integer number, without decimals conversion, or exact bigint. For example, tx.setValue(0.001)
<input onChange={(event) => setValue(() => +event.target.value)} value={value}
disabled={isSending} type="number" />
Properties
| Name | Type | Description |
|---|---|---|
| $value | ValueCell<Rational> | Represents a rational value. |
| function | AnyCell<AbiFunction> | Holds the ABI function details. |
| chainOK | AnyCell<boolean> | Checks if the target method is on the correct chain. |
| dcContract | AnyCell<SmartContract \| null> | Holds the smart contract details or null. |
| dcToken | AnyCell<EVMToken \| null> | Holds the EVM token details or null. |
| okContract | OKContract | Represents the OKContract instance. |
| contractChain | AnyCell<ChainType> | Represents the contract's blockchain network type. |
| chain | AnyCell<Chain> | Represents the blockchain network. |
| abi | AnyCell<ABI> | Contains the ABI (Application Binary Interface). |
| abix | AnyCell<ABIExtra> | Contains additional ABI information. |
| inputEnv | Environment | Basic environment data. |
| schema | AnyCell<TypeScheme> | Schema of the transaction. |
| data | AnyCell<Environment> | Transaction data derived from schema values. |
| editor | AnyCell<DataEditor> | Data editor instance. |
| env | MapCell<Environment, false> | OKTransaction environment. |
| missingInputs | MapCell<string[], false> | Missing input fields. |
| org | MapCell<string, false> | Organization details. |
| btnLabel | MapCell<string, false> | Label for a button. |
| title | MapCell<unknown[], false> | Title information. |
| info | MapCell<unknown[], false> | Additional information. |
| infoLine | MapCell<string, false> | Single line of information. |
| button | MapCell<Value<string>[], false> | Button configurations. |
| image | MapCell<unknown, boolean> | Image details. |
| allowances | MapCell<[string, Value<unknown>][], boolean> | Token allowances. |
| txInputs | MapCell<AnyCell<unknown>[], false> | Transaction input values. |
| inputsOK | MapCell<boolean, false> | Check if input values are valid. |
| isPreOk | MapCell<boolean, false> | Check if preconditions are met. |
| canSendTX | MapCell<boolean, false> | Check if the transaction can be sent. |
| skip | AnyCell<boolean> | Check if the transaction can be skipped. |
| encodedData | MapCell<'0x${string}', false> | Encoded transaction data. |
| tx | MapCell<{ tx: TXRequest; gas_amount: bigint }, false> | The transaction to be sent. |
| readOutput | MapCell<Record<number, AnyCell<unknown>>, false> | Output of the readonly method. |
| sentTx | ValueCell<SentTransaction[]> | The sent transaction details. |
| receipt | AnyCell<TransactionReceipt> | Transaction receipt. |
| receipts | ValueCell<TransactionReceipt[]> | List of transaction receipts. |
| rawLogs | AnyCell<AnyCell<Log>[]> | Raw logs from the transaction receipt. |
| $logs | AnyCell<AnyCell<AnalyzedLog>[]> | Analyzed logs from the transaction. |
| prettyLogs | AnyCell<unknown[]> | Prettified transaction logs. |
| isSending | ValueCell<boolean> | Indicates if the transaction is being processed. |
| isDone | ValueCell<boolean> | Indicates if the transaction has been processed. |
| decimals | AnyCell<Rational> | Decimal value representation. |
| tokenPriceData | AnyCell<TokenMarketData> | Market data for the token. |
| currency | AnyCell<EVMToken> | EVM token details. |