Explore Create a typescript rules engine in xstate that takes in a fiat or crypto transaction… Save Share Download ▾ ReportPrivate research annotation Sign in to add a private research label or note.
Create a typescript rules engine in xstate that takes in a fiat or crypto transaction which allows us to stop/approve withdrawals
Here's an example of how you might create a state machine using xstate in TypeScript to handle transactions:
Copy first prompt Copy first response
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Model Unknown
Provider unknown
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language Not recorded
Added to archive Nov 26, 2026
ID 01m8bdh2nybqqb49mk227jd574Source & license Imported from ShareGPT 90K (shared ChatGPT conversations) (source ). Imported records earn no Research Points.
Upstream record: HTML_cleaned_raw_dataset/sg_90k_part1_html_cleaned.json:8960
anon8231489123/ShareGPT_Vicuna_unfiltered, revision 192ab2185289094fc556ec8ce5ce1e8e587154ca
License: Apache-2.0 (as published by the uploader; same files as RyokoAI/ShareGPT52K, CC0)
Cite this conversation “Create a typescript rules engine in xstate that takes in a fiat or crypto transaction….” Conversation with an AI model, from the ShareGPT 90K (shared ChatGPT conversations) dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m8bdh2nybqqb49mk227jd574
Copy citation
import { Machine, assign } from 'xstate';
type Transaction = {
type: 'fiat' | 'crypto';
amount: number;
}
type TransactionContext = {
transaction: Transaction;
approved: boolean;
stopped: boolean;
}
const transactionMachine = Machine<TransactionContext>({
id: 'transaction',
initial: 'pending',
context: {
transaction: {
type: 'fiat',
amount: 0,
},
approved: false,
stopped: false,
},
states: {
pending: {
on: {
APPROVE: {
target: 'approved',
actions: assign({
approved: true,
}),
},
STOP: {
target: 'stopped',
actions: assign({
stopped: true,
}),
},
},
},
approved: {
// ...
},
stopped: {
// ...
},
},
});
This state machine has three states: pending, approved, and stopped. When a transaction is first created, it is in the pending state. From this state, the transaction can be either approved or stopped by sending the APPROVE or STOP event, respectively. When the transaction is approved, it transitions to the approved state, and when it is stopped, it transitions to the stopped state.
In the approved and stopped states, you can add additional behavior to handle the approved or stopped transaction. For example, you might want to log the transaction or perform some other action.
I hope this helps! Let me know if you have any other questions.
Dataset releases Not yet included in a published release.